• Resolved _jerryjee

    (@_jerryjee)


    I’m using WP_CLI develop the plugin , and using remove_all_actions to remove the actions , there are the code below :

                        remove_all_actions('pre_get_posts');
    
                        $args =  array(
                            'post_status' => array('publish', 'pending', 'draft', 'future', 'private', 'trash', 'auto-draft'),
                            'post_per_page' => -1,
                            'meta_query' => array(
                                array(
                                    'key'       => $this->JPost->source,
                                    'value'     => $single_url,
                                    'compare'   => '=',
                                ),
                            ),
                        );
    
                        $the_query = new WP_Query($args);
                        var_dump($the_query->posts);

    if there’s no search result ,it always return the leatest article , so i used remove_all_actions(‘pre_get_posts’); to remove all hooks .

    And it works in the browse , but not working in WP_CLI .
    Is this is a debug or something wrong with my code .

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator threadi

    (@threadi)

    I can’t reproduce that in my case. Without any plugins, WP_Query doesn’t give any results if there aren’t any. Which plugin is causing this change in the result for you?

    Thread Starter _jerryjee

    (@_jerryjee)

    This is the plugin i installed below :
    Advanced Custom Fields PRO
    All in One SEO
    Cloudflare
    Pinyin Slugs
    QQWorld Auto Save Images
    Query Monitor
    W3 Total Cache
    WordPress轻水印插件
    WP-JPost <– I’m developing this plugin .
    WPFront Scroll Top

    Moderator threadi

    (@threadi)

    Try deactivating all of them first to see if the behaviour changes. Then you can activate them bit by bit until it happens again.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘WP_CLI remove_all_actions not working’ is closed to new replies.