WP_Query meta_key being changed by WHP
-
I have the following WP_Query that is suppose to get the 6 most recent broadcasts ordered by the Monday’s start date (monday_start_date is a custom field), but the results are in random order because WHP seems to be overriding the meta_key. WHP is not enabled on the Broadcast custom post type.
$args = array( 'post_type' => 'broadcast', 'posts_per_page' => 6 , 'order' => 'DESC', 'orderby' => 'meta_value_num', 'meta_key' => 'monday_start_date', ); $the_query = new WP_Query($args); pr($the_query); // print_r wrapper
And here is a snippet of the output …
WP_Query Object ( [query] => Array ( [post_type] => broadcast [posts_per_page] => 6 [order] => DESC [orderby] => meta_value_num [meta_key] => monday_start_date ) [query_vars] => Array ( [post_type] => broadcast [posts_per_page] => 6 [order] => DESC [orderby] => meta_value_num [meta_key] => _whp_hide_on_cpt_archive [error] => ... ) ... )
Notice in the [query] section on the of the WP_Query Object the meta_key is set to what I asked it for, ie. “monday_start_date” but in the [query_vars] and key in [meta_query] sections it has been overridden with “_whp_hide_on_cpt_archive”. If I disable WHP then the meta_key and key revert to monday_start_date and WP_Query works as expected.
Current versions:
Wordpress 5.9.2
WHP 1.0.2I have only just picked up on the issue but I have confirmed that it has only broken in the following update.
WHP 0.5.4 => 1.0.1
Please help.
Kind Regards,
Pete
- The topic ‘WP_Query meta_key being changed by WHP’ is closed to new replies.