How to check if an opened page is a WC related page?

Question

I need to detect all the WC related pages ( products, single product, checkout, etc… ) in a website.

I’ve added the wp action in the functions.php and tried to do it using is_shop() function but it doesn’t work. Here is the code with which I’ve tried to achieve this

add_action('wp', 'page_loaded');

function page_loaded() {
   if (is_shop()) {
      // Some code here
   }
}

So, is there any way to achieve this?

0
, , ArmKh 3 years 2020-04-01T04:50:59-05:00 0 Answers 85 views 0

Leave an answer

Browse
Browse