Support » Fixing WordPress » PHP code error?

  • There appears to be an error in the following php code. Any idea?

    /**
    * @snippet Remove "Default Sorting" Dropdown @ WooCommerce Shop & Archive Pages
    */
    add_action( 'init', 'njengah_remove_default_sorting_storefront' );
    
    function njengah _remove_default_sorting_storefront() {
       remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
       remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
    }

    Error:
    syntax error, unexpected ‘_remove_default_sorting_storef’ (T_STRING), expecting ‘(‘

Viewing 3 replies - 1 through 3 (of 3 total)
  • Here:

    
    function njengah _remove_default_sorting_storefront()
    

    There’s a space between njengah and _remove_default_sorting_storefront that shouldn’t be there.

    @martini0 after removing the space in the function name, it is working fine. So can you please try after removing that?

    /**
    * @snippet Remove "Default Sorting" Dropdown @ WooCommerce Shop & Archive Pages
    */
    add_action( 'init', 'njengah_remove_default_sorting_storefront' );
    
    function njengah_remove_default_sorting_storefront() {
       remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
       remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
    }
    • This reply was modified 1 day, 14 hours ago by weboccults.
    Thread Starter martini0

    (@martini0)

    Got it, that was it indeed. However, the code is not working. I use Avada. I want to remove all woocommerce sorting via PHP. Not via CSS.

    https://avada.io/woocommerce/docs/remove-product-sorting.html

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.