WP_query sort by custom meta_key “price”
Thanks to Brad Dalton at wpsites.net for getting me to the answer. Install Advanced Custom Fields plugin. Create a custom field called price, formatted as a number. Use the code below (based on Bill Erickson’s tutorial): add_action( ‘pre_get_posts’, ‘kr_change_posts_order’ ); function kr_change_posts_order( $query ) { if ( $query->is_main_query() && !is_admin() && !is_page() ) { $orderby … Read more