Tagged: enfold, portfolio grid, random
Hi There,
I was slowly adding some test content into the theme and realise that it only display the Most Recent portfolio items, is there a way to display Random items that Exclude the current post item? Thanks!
Regards,
Robert Chai
Hi sgrobert!
You can change the order of the portfolio using this on 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);
Best regards,
Ismael
Hi Ismael,
So meaning I can’t do it through the Advanced Editor rather than through the Default Editor? In this case, I can’t edit the settings of the Post Grid though, do let me know if there is an alternative?
Regards,
Robert Chai
Hi!
You can do it on the Advance Layout Builder. It will sort the portfolio items on random order. Please try it.
Cheers!
Ismael
Hi Ismael,
So may I just clarify that if I insert the above code, it will by default auto-random the default grid? Please do let me know. Thanks!
Regards,
Robert Chai
Hi Ismael,
I’ve just tried and tested. Does looks like it works without additional codes. Thanks so much!
Regards,
Robert Chai
Hi Ismael,
I realized that I do need the two types of sorting working on the same website, meaning RANDOM and MOST RECENT. Thus, would there be an alternative to have the choice of calling up either or within the Advanced Editor? Thanks.
Regards,
Robert Chai
Hey!
No, unfortunately not as far as I know. The filter adds the random to the query for all queries so for right now since there isn’t a theme option available its either an all or nothing change.
I’ll add the idea for a future update for a random option within the shortcode options however.
Cheers!
Devin
+1 for a random option ;)
Torsten