Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #286562

    Hello , i have a problem in using portfolio grid when i want to display portfolio item randomly .

    Please check my page , i want to display random product in same category under “You may also interested following items” .

    Could you check and tell if it is possible to do that and how it going ?

    #286638

    Hey garbath!
    Thank you for using our theme.

    Actually you can change the order with a filter – i.e. add following code to the bottom of functions.php:

    
    function custom_post_grid_query( $query, $params ) {
    $query['orderby'] = 'rand';
    return $query;
    }
    add_filter( 'avia_post_grid_query', 'custom_post_grid_query', 10, 2);
    

    and all portfolio grids will use a random order for the entries. However the tricky part is to change the order of some grids only. I recommend to change the order based on the current page id – in your case the code would look like

    
    function custom_post_grid_query( $query, $params ) {
    if(is_page(array(42,50,45))) $query['orderby'] = 'rand';
    return $query;
    }
    add_filter( 'avia_post_grid_query', 'custom_post_grid_query', 10, 2);
    

    and instead of 42, 50, 45 insert the page ids of those pages which should display the portfolio grid(s) in a random order. You can separate the ids with a comma.

    Best regards,
    Günter

    #287484
    This reply has been marked as private.
    #287486

    Hi!

    Glad we could help you.

    Thank’s for visiting our forum and enjoy the theme.

    Best regards,
    Günter

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘how to make random display portfolio items in short code – portfolio grid’ is closed to new replies.