Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #223529

    Is there a way to randomize the grid layout blog posts?

    #223815

    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

    #223824

    How about that, but only on specific posts and pages?

    #224495

    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

    #232237

    Either one doesn’t seem to make the Masonry Grid change. Any suggestions?

    Thank you,

    #233115

    Hey!

    I used the wrong filter name – I corrected the code above, please try it again.

    Best regards,
    Peter

    #236339

    Wonderful. thank you.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Randomize Grid Layout’ is closed to new replies.