-
AuthorPosts
-
October 27, 2014 at 7:11 pm #341690
Hello
Is is possible to randomize posts that are displayed in the new magazine elements ?
thanksOctober 29, 2014 at 8:54 am #342609Hi pako69!
Line 366 in (theme folder)/config-templatebuilder/avia-shortcodes/magazine.php
Change the following:
$query = array( 'orderby' => 'date',To this:
$query = array( 'orderby' => 'rand',Note that this will be overwritten upon a theme update. Please make a note of this change during updates.
Regards,
ArvishOctober 29, 2014 at 9:15 am #342617Hey @Arvish thanks it works :-)
Is is possible to set a range of date?
thanksOctober 31, 2014 at 5:03 am #343860Hey!
No, unfortunately, it’s not possible to specify data range. Instead of modifying the magazine.php file, please add this on functions.php:
add_filter('avf_magazine_entries_query', 'avf_magazine_entries_custom_query'); function avf_magazine_entries_custom_query ( $query ) { $query['orderby'] = 'rand'; $query['order'] = 'DESC'; return $query; }Refer to the wp codex for more order and orderby parameters.
Best regards,
IsmaelOctober 31, 2014 at 11:22 am #343941Hello @Ismael
Great :-) Better than modifiying Enfold core files.
I’ve found some tricks that can do what I want :RANDOM AND POST FROM THE CURRENT MONTH :
add_filter('avf_magazine_entries_query', 'avf_magazine_entries_custom_query'); function avf_magazine_entries_custom_query ( $query ) { $query['orderby'] = 'rand'; $query['order'] = 'DESC'; $current_month = date('m'); $query['monthnum'] = $current_month; return $query;RANDOM AND POSTS FROM THE LAST 5 WEEKS
add_filter('avf_magazine_entries_query', 'avf_magazine_entries_custom_query'); function avf_magazine_entries_custom_query ( $query ) { $query['orderby'] = 'rand'; $query['order'] = 'DESC'; $query['date_query'] = array( array( 'after' => '5 week ago' ) ); return $query; }With the help of :
https://tommcfarlin.com/get-posts-from-last-week/
and
http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters -
AuthorPosts
- The topic ‘Display Magazine posts in a random order’ is closed to new replies.
