woocommerce hooks and is_shop() / is_archive()

Viewed 1831

I want to do two things:

  1. remove the breadcrumbs in category pages, but leave it in single product pages.
  2. remove the title from the shop page.

For the breadcrumbs, I tried this code and it doesn't work:

if( is_archive() ){
    add_action( 'init', 'porto_remove_wc_breadcrumbs' );
    function porto_remove_wc_breadcrumbs() {
        remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
    } 
}

(without the conditional tag it does work, or if I change the conditional to if(1<2) instead). no matter what archive page i'm displaying, with the code above the breadcrumbs is shown.

About the second problem, this code doesn't work either:

if( is_shop() ){
    add_filter( 'woocommerce_show_page_title' , 'woo_hide_page_title' );

    function woo_hide_page_title() {

        return false;

    }
}

There's still title in shop page after running this code. I guess the solution for both problems are the same.

What am I doing wrong?

0 Answers
Related