Last active
July 17, 2017 18:29
-
-
Save gspice/d3b4741ba40bdf0a4fdf to your computer and use it in GitHub Desktop.
Finally solved! Code to sort AgentPress Listings by price. Thanks to Carrie Dils showing the thread in github for this -- update was suggested by Andrew Norcross that was added to the plugin code. A sortable column was added called listing_price_sortable. This allowed only the numeric value of the price to be stored separately and updated each t…
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 price high to low | |
add_action( 'pre_get_posts', 'gsc_listing_price_sort_order' ); | |
function gsc_listing_price_sort_order( $query ) { | |
if( !is_admin() && is_post_type_archive( 'listing' ) ) { | |
$query->set( 'meta_key', '_listing_price_sortable' ); | |
$query->set( 'orderby', 'meta_value_num' ); | |
$query->set( 'order', 'desc' ); //list high to low | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This succeeded in sorting my listings by price, but it removed the listings' thumbnail images from the homepage. Has anyone else experienced this issue, and is there a known solution at this time?