-
psrios
Hi guys, I hope you are all doing great!
I have this site here in which there the “trending now” div (on the right) I would like to change the query loop to display random posts instead of the latest posts. How can I do it? many thanks! the site link is posted below
-
Hi there,
To randomly order the posts is a GB Pro feature.
If you have GB pro, you can add
order random
parameter. -
psrios
i dont have pro :/
-
psrios
I found this thread, if I add this code, would I be able to have it working? thanks
https://wordpress.org/support/topic/query-loop-random-selection-of-posts/
-
Yes, that’s the right code, and you need to add the class
my-class-name
to the Grid block of the query loop.You can change the class to anything else, just make sure they match.
-
psrios
I will try out thank you!
-
psrios
Hi Ying,
How exaclty do I use it? I know how to add the PHP code, and add the class my-class-name to the Grid block of the query loop, but then is there any other step? thank you
-
psrios
it returns the following error
Your PHP code changes were not applied due to an error on line 22 of file wp-content/themes/generatepress_child/functions.php. Please fix and try saving again.
syntax error, unexpected token “)”
-
psrios
Hi Ying, good news it is working now thank you! have a lovely day!
-
psrios
ah just another question, how can i exclude some categories for example, I can see featuring Halloween posts as it is not Halloween id like to exclude them for the moment =) thank you!
-
Fernando
Hi there,
You can add an exclude parameter to exclude a taxonomy in your Query Loop.
Your code shouldn’t override that parameter. It should just append the parameter.
-
psrios
Hi Fernando!perfect! Thank you all, guys. Great work!
-
Fernando
You’re welcome!
- You must be logged in to reply to this topic.