Created
February 7, 2015 00:00
-
-
Save Jonnyauk/16aefac2db04485b2da9 to your computer and use it in GitHub Desktop.
pre_get_posts example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mywfx_archive_order_by_title($query) { | |
if ( !is_admin() && $query->is_main_query() ) { | |
if ( is_post_type_archive( ‘kitty’ ) { | |
$query->set( 'orderby', 'title' ); | |
$query->set( 'order', 'ASC' ); | |
} | |
return $query; | |
} | |
} | |
add_action( 'pre_get_posts', 'mywfx_archive_order_by_title', 1 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment