下面是我想在搜索结果页面中禁用的插件代码。它会影响我的结果,并以一种奇怪的方式显示它们。所以我想在这个页面上禁用它。这就是了。
class WC_PSAD
{
public function WC_PSAD() {
$this->init();
}
public function init () {
add_filter('loop_shop_per_page', array( $this, 'limit_posts_per_page'),99);
//Fix Responsi Theme.
add_action( 'a3rev_head', array( $this, 'remove_responsi_action'), 11 );
add_action( 'woo_head', array( $this, 'remove_responsi_action'), 11 );
add_action( 'wp_head', array( $this, 'remove_woocommerce_pagination'), 10 );
add_action( 'woocommerce_after_shop_loop', array( $this, 'woocommerce_pagination') );
//Check if shop page
add_action( 'woocommerce_before_shop_loop', array( $this, 'check_shop_page'), 1 );
// For Shop page
add_action( 'woocommerce_before_shop_loop', array( $this, 'start_remove_orderby_shop'), 2 );
add_action( 'woocommerce_before_shop_loop', array( $this, 'end_remove_orderby_shop'), 40 );
add_action( 'woocommerce_before_shop_loop', array( $this, 'dont_show_product_on_shop'), 41 );
add_action( 'woocommerce_after_shop_loop', array( $this, 'rewrite_shop_page'), 12 );我想删除这4个操作“为商店页”,仅搜索结果页。我该怎么做?
编辑:编辑:我所要做的就是检查参数url:
public function WC_PSAD() {
if(!isset($_GET["s"]) ){
$this->init(); }
}谢谢你的回答!
发布于 2015-10-02 10:02:12
你可以直接用is_search()
if(!is_search()) {
// For Shop page
add_action( 'woocommerce_before_shop_loop', array( $this, 'start_remove_orderby_shop'), 2 );
add_action( 'woocommerce_before_shop_loop', array( $this, 'end_remove_orderby_shop'), 40 );
add_action( 'woocommerce_before_shop_loop', array( $this, 'dont_show_product_on_shop'), 41 );
add_action( 'woocommerce_after_shop_loop', array( $this, 'rewrite_shop_page'), 12 );
}发布于 2015-10-02 10:12:08
基于@vard的答案,但是有倒转的行为:(这两种方法都应该有效)
<?php
if( is_search() ) {
// Remove actions on search page
remove_action( 'woocommerce_before_shop_loop', array( $this, 'start_remove_orderby_shop'), 2 );
remove_action( 'woocommerce_before_shop_loop', array( $this, 'end_remove_orderby_shop'), 40 );
remove_action( 'woocommerce_before_shop_loop', array( $this, 'dont_show_product_on_shop'), 41 );
remove_action( 'woocommerce_after_shop_loop', array( $this, 'rewrite_shop_page'), 12 );
}https://stackoverflow.com/questions/32904803
复制相似问题