Skip to content

Instantly share code, notes, and snippets.

@ayezee33
Last active December 6, 2015 05:17
Show Gist options
  • Save ayezee33/e74baea6b57189c6666e to your computer and use it in GitHub Desktop.
Save ayezee33/e74baea6b57189c6666e to your computer and use it in GitHub Desktop.
Reverse order posts in wordpress
//Reverse Podcast Order
function podcast_order( $wp_query ) {
// Get the post type from the query
if( isset($wp_query->query['post_type']) ) {
$post_type = $wp_query->query['post_type'];
if ($post_type == 'podcasts') {
$wp_query->set('orderby', 'date');
$wp_query->set('order', 'ASC');
}
}
}
add_filter('pre_get_posts', 'podcast_order');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment