Search
Close this search box.
Search
Close this search box.

WooCommerce conditional tags

WooCommerce makes it a snap to programmatically determine the current page through the use of their Conditional Tags. These functions can be used to check whether the current page is the shop page: is_shop(), or a product page: is_product(). See WooCommerce Conditional for the full list.

The WordPress/WooCommerce conditional tags won’t work until after the wp action is fired, making it the earliest point at which you can use the tags. You can view the entire list, and the order of the core WordPress actions at the Action Reference page.

add_action( 'wp', 'init' );
function init() {
  if ( is_shop() ) {
    // yipee, this works!
  }
}