Is there a way to randomize the grid layout blog posts?
Hey paulann!
You can add this on functions.php:
add_filter('avia_post_slide_query','avia_order_by_random', 10, 2);
function avia_order_by_random($query, $params)
{
$query['orderby'] = 'rand';
return $query;
}
Regards,
Ismael
How about that, but only on specific posts and pages?
Hi!
You can use the is_page and is_single conditional: ( http://codex.wordpress.org/Function_Reference/is_page and http://codex.wordpress.org/Function_Reference/is_single ) to change the query parameter on some pages/posts. Use it like:
add_filter('avia_masonry_entries_query','avia_order_by_random', 10, 2);
function avia_order_by_random($query, $params)
{
if(is_single(array(17,19,25))) $query['orderby'] = 'rand';
if(is_page(array(40,49,30))) $query['orderby'] = 'rand';
return $query;
}
and instead of 17,19,25 insert the post ids (posts where you want to show a random grid) and instead of 40,49,30 insert your page ids. Separate them with a comma.
Regards,
Peter
Either one doesn’t seem to make the Masonry Grid change. Any suggestions?
Thank you,
Hey!
I used the wrong filter name – I corrected the code above, please try it again.
Best regards,
Peter
Wonderful. thank you.