- Hi Ben, 
 Thank you for posting.
 Since BuddyBlog utilises WP_Query for listing posts, you can use the orderby=rand for randomizing the posts list.- Please see all the orderby options here - https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters - Hope that helps. - Regards 
 Brajesh
- Hi brajesh, - I created a function for use in the bp-custom and it works well, 
 Thank you for the input 🙂
 I’ve added the code below just incease someone else wants to do the same.
 Ben
 add_action('pre_get_posts','randomize_query');
 function randomize_query($query){
 if ($query->set('orderby', 'rand')); //Set the order to random
 }
 
- EDIT: 
 I forgot to make sure it knew it’s for posts, The way I had it then pages were randomised to, very annoying when you’re trying to find a page lol
 
 add_action('pre_get_posts','randomize_query');
 function randomize_query($query){
 if ($query->have_posts()) //Check that you have posts and now knows it's for posts
 $query->set('orderby', 'rand'); //Set the order to random
 }
 
- Thank you Ben. 
 You already realized it. I will also suggest completely avoiding pre_get_posts as it will have side effect.- It will better to directly modify the template in this case. If you still want to use pre_get_posts, I suggest pairing it with the following conditions - if ( function_exists( 'bp_is_buddyblog_component' ) && bp_is_buddyblog_component() ) { }- Regards 
 Brajesh
You must be logged in to reply to this topic.
