• I want to remove the sorting options from my shop page here using remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );

    It works fine on other sites, but not this one (using Nova WP theme, child of Storefront).

    When I add

    global $wp_filter;
    echo '<pre>';
    var_dump( $wp_filter['woocommerce_before_shop_loop'] );
    echo '</pre>';

    to my archive-product.php the output is this:

    array(5) {
      [10]=>
      array(2) {
        ["wc_print_notices"]=>
        array(2) {
          ["function"]=>
          string(16) "wc_print_notices"
          ["accepted_args"]=>
          int(1)
        }
        ["woocommerce_catalog_ordering"]=>
        array(2) {
          ["function"]=>
          string(28) "woocommerce_catalog_ordering"
          ["accepted_args"]=>
          int(1)
        }
      }
      [9]=>
      array(1) {
        ["storefront_sorting_wrapper"]=>
        array(2) {
          ["function"]=>
          string(26) "storefront_sorting_wrapper"
          ["accepted_args"]=>
          int(1)
        }
      }
      [20]=>
      array(1) {
        ["woocommerce_result_count"]=>
        array(2) {
          ["function"]=>
          string(24) "woocommerce_result_count"
          ["accepted_args"]=>
          int(1)
        }
      }
      [30]=>
      array(1) {
        ["storefront_woocommerce_pagination"]=>
        array(2) {
          ["function"]=>
          string(33) "storefront_woocommerce_pagination"
          ["accepted_args"]=>
          int(1)
        }
      }
      [31]=>
      array(1) {
        ["storefront_sorting_wrapper_close"]=>
        array(2) {
          ["function"]=>
          string(32) "storefront_sorting_wrapper_close"
          ["accepted_args"]=>
          int(1)
        }
      }
    }

    PLease help?

Viewing 1 replies (of 1 total)
  • Thread Starter prandrews73

    (@prandrews73)

    OK I’ve finally found an answer to this [here][1]. It seems that the “storefront” theme behaves differently to other themes in this regard. What is needed to remove the sorting drop down is:

    // remove default sorting dropdown in StoreFront Theme
    add_action('init','delay_remove');
    function delay_remove() {
    remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
    }

    as opposed to the more obvious-seeming

    // remove default sorting dropdown
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );

    [1]: https://businessbloomer.com/woocommerce-remove-default-sorting-dropdown/

Viewing 1 replies (of 1 total)
  • The topic ‘[woocommerce] Remove Action Doesn't Work’ is closed to new replies.