Home > database >  How to add a function only to woocommerce pages
How to add a function only to woocommerce pages

Time:03-31

I have this code I put in to remove part of my breadcrumbs in woocommerce which said "Products" in the second crumb:

if( $item_position === 2 ){continue;}

While it does work, it also removes the second breadcrumb from my other pages, while I just want it to remove it from woocommerce so I tried:

if ( is_woocommerce && $item_position === 2 ){continue;}

Which did the same as the previous, and I also tried:

if (is_woocommerce ($item_position === 2 ){continue;}

Which now works on my other pages but will completely remove breadcrumbs from woocommerce. I'm just learning and I have no idea what i'm doing wrong.

CodePudding user response:

is_woocommerce() is a function.

The correct syntax is:

if (is_woocommerce() && $item_position === 2 ) { 
    continue; 
}
  • Related