Created
July 21, 2015 15:21
-
-
Save gspice/376700389d2f89b92f21 to your computer and use it in GitHub Desktop.
AgentPress Listings - change sort order to be by state. In CPT, this is 'listing_state'
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
//change sort order to listing_state in main query | |
add_action( 'pre_get_posts', 'gsc_listing_state_sort_order' ); | |
function gsc_listing_state_sort_order( $query ) { | |
if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'listing' ) ) { | |
$query->set( 'orderby', 'listing_state' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment