Skip to content

Instantly share code, notes, and snippets.

@moxdev
Created February 13, 2019 22:31
Show Gist options
  • Save moxdev/7391584b216ec9c1b4724d82a48ab1e8 to your computer and use it in GitHub Desktop.
Save moxdev/7391584b216ec9c1b4724d82a48ab1e8 to your computer and use it in GitHub Desktop.
Display Taxonomy Posts in Ascending Alphabetical Order By Title #wp
add_action( 'pre_get_posts', 'quantum_custom_property_locations_query_order' );
/**
* Display Taxonomy Property Locations Page in Ascending Alphabetical Order By Title
*
* @link https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
* @param object $query pre_get_posts WP_Query.
* @return void
*/
function quantum_custom_property_locations_query_order( $query ) {
if ( $query->is_tax( 'property_locations' ) && $query->is_main_query() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment