Skip to content

Instantly share code, notes, and snippets.

@skyshab
Created September 20, 2018 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyshab/398dd54a41389c39b682a3c32c5dc716 to your computer and use it in GitHub Desktop.
Save skyshab/398dd54a41389c39b682a3c32c5dc716 to your computer and use it in GitHub Desktop.
Push long running events to bottom on home page
<?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