Tagged: portfolio grid
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 ?
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