Skip to content

Instantly share code, notes, and snippets.

@andrasguseo

andrasguseo/functions.php

Last active Nov 30, 2016
Embed
What would you like to do?
Modify query order when including events in blog post loop
/*
* Template to modify query order when including events in blog post loop
* For The Events Calendar
* Paste into functions.php
*/
add_action( 'pre_get_posts', 'order_by_modified' );
function order_by_modified( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set ( 'order', 'asc'); // Use this to sort 'oldest first'
// $query->set ( 'order', 'desc'); // Use this to sort 'newest first'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment