remove_action from wordpress plugin in search result page

here is my plugin code i want to disable in search result page.
It affects my results and displays them in an odd way. So i want to disable it in this page. Here it is.

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 );

I want to remove these 4 action ” FOR SHOP PAGE” only for search result page.
How can i do that please ?

Read More

EDIT : EDIT : all i have to do is check the argument url :

public function WC_PSAD() { 
        if(!isset($_GET["s"]) ){        
        $this->init();          } 
    }

Thank you for your answers !

Related posts

2 comments

  1. You could just use 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 );
    }
    
  2. Based on the answer of @vard, but with inverted behavior: (both methods should work)

    <?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 );
    }
    

Comments are closed.