Php Wordpress从主题中删除插件过滤器

Php Wordpress从主题中删除插件过滤器,php,wordpress,hook,Php,Wordpress,Hook,我需要删除插件woocommerce批发专业版的过滤器。过滤器添加到文件woocommerce-wholesale-pricing-pro.php中,如下所示: class IGN_Wholesale_Pro_Suite { function init() { add_filter( 'loop_shop_post_in', array( $this, 'product_filter' ) ); ... } function produ

我需要删除插件woocommerce批发专业版的过滤器。过滤器添加到文件woocommerce-wholesale-pricing-pro.php中,如下所示:

class IGN_Wholesale_Pro_Suite {
    function init() {
        add_filter( 'loop_shop_post_in', array( $this, 'product_filter' ) );

        ...
    }

    function product_filter( $meta_query = array() ) {
        ...
    }
}
到目前为止,我已经尝试在我的主题中将其添加到functions.php中:

function removeIGNfilter()
{
    remove_filter( 'loop_shop_post_in', array('IGN_Wholesale_Pro_Suite', 'product_filter') );
}
add_action('init','removeIGNfilter', 15);
add_action('plugins_loaded','removeIGNfilter', 15);
我还尝试添加:

remove_filter( 'loop_shop_post_in', array('IGN_Wholesale_Pro_Suite', 'product_filter') );
之后:

add_filter( 'loop_shop_post_in', array( $this, 'product_filter' ) );
在插件文件的init()函数中,但它不起作用。但当我把它改成这个:

remove_filter( 'loop_shop_post_in', array($this, 'product_filter') );
它起作用了


有什么方法可以从我的主题中删除此过滤器吗?

您可以使用下面的方法

// below code is only testing not used to functions.php


class IGN_Wholesale_Pro_Suite {
function init() {
    add_filter( 'loop_shop_post_in', array( $this, 'product_filter' ) );
}
function product_filter( $meta_query = array() ) {
}
}

//only user for below code
$plugin_class_name = new IGN_Wholesale_Pro_Suite();
remove_action('loop_shop_post_in', array($plugin_class_name, 'product_filter'));

在remove_filter中,而不是$this,您必须将使用的实例放在“add_filter”中