Skip to content

Instantly share code, notes, and snippets.

@ControlledChaos
Last active August 8, 2017 18:40
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 ControlledChaos/14e3f334cc2ef7b2d4a665876902458b to your computer and use it in GitHub Desktop.
Save ControlledChaos/14e3f334cc2ef7b2d4a665876902458b to your computer and use it in GitHub Desktop.
Order post type archive pages by menu order for use with sort order plugins.

Menu Order Archives

WordPress Snippet

<?php
function ccd_query_vars( $query ) {
if ( ! is_admin() && $query->is_main_query() && is_post_type_archive( 'post_type_slug' ) ) {
$query->set( 'orderby', 'menu_order' );
$query->set( 'order', 'ASC' );
return $query;
}
return $query;
}
add_action( 'parse_query', 'ccd_query_vars' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment