Ordering Post by Meta Key (Not Working)

Had same issue. Have spent like few hours searching for the problem and it turned out to be just a typo: instead of incorrect order_by you should use orderby – without the underscore. So, this should work: $args = array( ‘post_type’ => ‘event’, ‘meta_key’ => ‘events_startdate’, ‘orderby’ => ‘meta_value’, ); $post_query = new WP_Query( $args … Read more

wp_set_post_terms not updating with WP Cron Event

Now Working with Wp Query – Thanks to Milo in the comments add_action(‘cvl_job_status_cron’, ‘cvl_mark_as_expired’); function cvl_mark_as_expired() { global $post; $args = array( ‘post_type’ => array( ‘job_listing’ ), ‘posts_per_page’ => ‘-1’, ‘fields’ => ‘ids’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘cvl_job_status’, ‘terms’ => ‘live’, ‘field’ => ‘slug’, ‘include_children’ => false, ), ), ); … Read more

Adding orderby url parameter to main CPT admin menu link

You can set $_GET directly inside your pre_get_posts action to get the UI to pickup that change: function wpd_test_pre_get( $query ) { // put whatever conditions to target your cpt here if( is_admin() && $query->is_main_query() ){ // modify query $query->set(‘orderby’, ‘title’); $query->set(‘order’, ‘asc’); // set $_GET vars $_GET[‘orderby’] = ‘title’; $_GET[‘order’] = ‘asc’; } } … Read more