Created
September 20, 2018 15:43
-
-
Save skyshab/398dd54a41389c39b682a3c32c5dc716 to your computer and use it in GitHub Desktop.
Push long running events to bottom on home page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Reorder events so that the ones that are running over a long period | |
* show up at the bottom of the list in a given view | |
*/ | |
add_action( 'pre_get_posts', 'push_older_events_to_bottom', 500 ); | |
function push_older_events_to_bottom( $query ) { | |
if ( is_front_page() ) { | |
$query->set( 'orderby', 'meta_value' ); | |
$query->set( 'meta_key', '_EventStartDate' ); | |
$query->set( 'order', 'DESC' ); | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment