WP Query with meta queries

You have to use “orderby” => “meta_value_num” and set a “meta_query” at the same time. Then choose the “meta_key” you want to order by. Try: $query = new WP_Query( array( ‘post_type’ => ‘some_cpt’, ‘posts_per_page’ => – 1, ‘meta_query’ => array( array( ‘key’ => ‘active’, ‘value’ => ‘1’, ‘compare’ => ‘=’, ) ), ‘meta_key’ => ‘ranking’, … Read more

Save_post acf data not updating category of post type

You can not use is_single() conditional tag here. You can check the type of post in the function this way: add_action( ‘save_post’, ‘set_genre_on_save’, 20, 3 ); function set_genre_on_save( $post_id, $post, $update ) { if ($post->post_type != ‘hvm’) return; // … } You can also attach the function to the action hook save_post_{post_type}, which is triggered … Read more