is_product_tag()
Checks if the current page is a product tag page. Conditional tag.
This is a wrapper for the function is_tax():
is_tax( 'product_tag', $term );
Uses: is_tax()
No Hooks.
Returns
true|false.
Usage
is_product_tag( $term );
- $term(string/array/number)
- The name, slug, or ID of the product tag. If nothing is specified, the function will simply check if we are on any product tag page.
Default: ''
Examples
#1 Find out if we are on a WooCommerce product tag page
if( is_product_tag() ) {
// this is the product tag page
}
else {
// this is another page (not the product tag)
} #2 Check that we are on a certain product tag page
Check the product tag page for the 'custom-tag' slug:
if( is_product_tag( 'custom-tag' ) ){
// product tag 'custom-tag'
}
Let's check by taxonomy term ID:
if( is_product_tag( 55 ) ){
// tag with ID 55
}
Let's check several tags at once - whether we are on the page of any of them:
if( is_product_tag( [ 50, 55 ] ){
// this is a page of one of the tags with ID 50 or 55
}
is_product_tag() is product tag code WC 10.7.0
function is_product_tag( $term = '' ) {
return is_tax( 'product_tag', $term );
}