WP_Query::is_tag() – Is the query for an existing tag archive page?
You appear to be a bot. Output may be restricted
Description
Is the query for an existing tag archive page?
If the $tag parameter is specified, this function will additionally check if the query is for one of the tags specified.
Usage
$bool = WP_Query::is_tag( $tag );
Parameters
- $tag
- ( int|string|int[]|string[] ) optional – Optional. Tag ID, name, slug, or array of such to check against. Default empty.
Returns
bool Whether the query is for an existing tag archive page.
Source
File name: wordpress/wp-includes/class-wp-query.php
Lines:
1 to 26 of 26
public function is_tag( $tag = '' ) { if ( ! $this->WP_Query::is_tag ) { return false; } if ( empty( $tag ) ) { return true; } $tag_obj = $this->WP_Query::get_queried_object(); if ( ! $tag_obj ) { return false; } $tag = array_map( 'strval', (array) $tag ); if ( in_array( (string) $tag_obj->term_id, $tag, true ) ) { return true; } elseif ( in_array( $tag_obj->name, $tag, true ) ) { return true; } elseif ( in_array( $tag_obj->slug, $tag, true ) ) { return true; } return false; }