GeekShop blog 'Other Posts You May Like' section issue

stantyan

Mar 29th, 2017 02:01 PM

Hi Admin,

I've added about 20 blog posts, and 'Other Posts You May Like' displays ONLY the first 4 blog posts I've added. Should it display randomly 4 posts out of all blog posts? If not, how can I achieve this?

https://app.box.com/s/16mytxdo9pcrkgop74pr50rji7t5pmu7

devdojo

Mar 30th, 2017 12:29 AM

Good call :) You're right.

I'll add this fix in the next update. In the meantime you can change line 20 inside of app/Http/Controllers/PostController.php from:

$random_posts = Post::where('id', '<>', $post->id)->take(4)->get();

to:

$random_posts = Post::inRandomOrder()->where('id', '<>', $post->id)->take(4)->get();

And you should be good to go. Thanks!

Talk to you soon.

stantyan

Mar 30th, 2017 11:19 AM

Awesome! Thank you!!!