Why my query is not "Main_query"?
I made a new page in admin panel like this. I want my Query here to be main_query so the other plugins could hook it, modify limits, etc...
add_action('admin_menu', function (){
add_submenu_page('edit.php?post_type=ticket', __('Board', 'askanban'), __('Board', 'askanban'), 'edit_posts', 'askanban', array( $this, 'askanban_display_board' ), 1);
});
public function askanban_display_board(){
$args = array(
'post_type' = 'ticket',
'posts_per_page' = - 1,
);
$query = new \WP_Query( $args );
$query-is_main_query(); // FALSE HERE!!!!!!!
$posts = $query-posts;
print_r($posts);
}
I read tons of info like this How to know which one is the main query? , this https://wp-qa.com/can-i-set-my-wp_query-to-be-a-main-query or When should you use WP_Query vs query_posts() vs get_posts()?
I tried to use get_posts()
and even tried to set $GLOBALS['wp_query'] = new \WP_Query( $args )
or $GLOBALS['wp_the_query'] = new \WP_Query( $args );
Noting helps. The other plugin can't see this query as main. For this other plugin there is no main query on this page. Why?