is_tag example

$cat       = $wp_query->get_queried_object();
            $classes[] = 'category';
            if ( isset( $cat->term_id ) ) {
                $cat_class = sanitize_html_class( $cat->slug, $cat->term_id );
                if ( is_numeric( $cat_class ) || ! trim( $cat_class, '-' ) ) {
                    $cat_class = $cat->term_id;
                }

                $classes[] = 'category-' . $cat_class;
                $classes[] = 'category-' . $cat->term_id;
            }
        } elseif ( is_tag() ) {
            $tag       = $wp_query->get_queried_object();
            $classes[] = 'tag';
            if ( isset( $tag->term_id ) ) {
                $tag_class = sanitize_html_class( $tag->slug, $tag->term_id );
                if ( is_numeric( $tag_class ) || ! trim( $tag_class, '-' ) ) {
                    $tag_class = $tag->term_id;
                }

                $classes[] = 'tag-' . $tag_class;
                $classes[] = 'tag-' . $tag->term_id;
            }
        }

function is_tag( $tag = '' ) {
    global $wp_query;

    if ( ! isset( $wp_query ) ) {
        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
        return false;
    }

    return $wp_query->is_tag( $tag );
}

/** * Determines whether the query is for an existing custom taxonomy archive page. * * If the $taxonomy parameter is specified, this function will additionally * check if the query is for that specific $taxonomy. * * If the $term parameter is specified in addition to the $taxonomy parameter, * this function will additionally check if the query is for one of the terms * specified. * * For more information on this and similar theme functions, check out * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ * Conditional Tags} article in the Theme Developer Handbook. * * @since 2.5.0 * * @global WP_Query $wp_query WordPress Query object. * * @param string|string[] $taxonomy Optional. Taxonomy slug or slugs to check against. * Default empty. * @param int|string|int[]|string[] $term Optional. Term ID, name, slug, or array of such * to check against. Default empty. * @return bool Whether the query is for an existing custom taxonomy archive page. * True for custom taxonomy archive pages, false for built-in taxonomies * (category and tag archives). */
if ( false !== $author
                && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) )
            ) {
                $redirect_url = get_author_posts_url( $author->ID, $author->user_nicename );
                $redirect_obj = $author;

                if ( $redirect_url ) {
                    $redirect['query'] = remove_query_arg( 'author', $redirect['query'] );
                }
            }
        } elseif ( is_category() || is_tag() || is_tax() ) { // Terms (tags/categories).             $term_count = 0;

            foreach ( $wp_query->tax_query->queried_terms as $tax_query ) {
                if ( isset( $tax_query['terms'] ) && is_countable( $tax_query['terms'] ) ) {
                    $term_count += count( $tax_query['terms'] );
                }
            }

            $obj = $wp_query->get_queried_object();

            if ( $term_count <= 1 && ! empty( $obj->term_id ) ) {
                
    } elseif ( is_tax() ) {
        $title['title'] = single_term_title( '', false );

        /* * If we're on the blog page that is not the homepage * or a single post of any post type, use the post title. */
    } elseif ( is_home() || is_singular() ) {
        $title['title'] = single_post_title( '', false );

        // If on a category or tag archive, use the term title.     } elseif ( is_category() || is_tag() ) {
        $title['title'] = single_term_title( '', false );

        // If on an author archive, use the author's display name.     } elseif ( is_author() && get_queried_object() ) {
        $author         = get_queried_object();
        $title['title'] = $author->display_name;

        // If it's a date archive, use the date as the title.     } elseif ( is_year() ) {
        $title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );

    }

            }

            $posts_page = esc_url( $posts_page );
            if ( 'list' === $parsed_args['style'] ) {
                $output .= "<li class='cat-item-all'><a href='$posts_page'>$show_option_all</a></li>";
            } else {
                $output .= "<a href='$posts_page'>$show_option_all</a>";
            }
        }

        if ( empty( $parsed_args['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) {
            $current_term_object = get_queried_object();
            if ( $current_term_object && $parsed_args['taxonomy'] === $current_term_object->taxonomy ) {
                $parsed_args['current_category'] = get_queried_object_id();
            }
        }

        if ( $parsed_args['hierarchical'] ) {
            $depth = $parsed_args['depth'];
        } else {
            $depth = -1; // Flat.         }
        
/** * Gets the REST route for the currently queried object. * * @since 5.5.0 * * @return string The REST route of the resource, or an empty string if no resource identified. */
function rest_get_queried_resource_route() {
    if ( is_singular() ) {
        $route = rest_get_route_for_post( get_queried_object() );
    } elseif ( is_category() || is_tag() || is_tax() ) {
        $route = rest_get_route_for_term( get_queried_object() );
    } elseif ( is_author() ) {
        $route = '/wp/v2/users/' . get_queried_object_id();
    } else {
        $route = '';
    }

    /** * Filters the REST route for the currently queried object. * * @since 5.5.0 * * @param string $link The route with a leading slash, or an empty string. */
/** * Renders the `core/term-description` block on the server. * * @param array $attributes Block attributes. * * @return string Returns the description of the current taxonomy term, if available */
function render_block_core_term_description( $attributes ) {
    $term_description = '';

    if ( is_category() || is_tag() || is_tax() ) {
        $term_description = term_description();
    }

    if ( empty( $term_description ) ) {
        return '';
    }

    $classes = array();
    if ( isset( $attributes['textAlign'] ) ) {
        $classes[] = 'has-text-align-' . $attributes['textAlign'];
    }
    
if ( $content_found ) {
                $set_404 = false;
            }

            // We will 404 for paged queries, as no posts were found.         } elseif ( ! is_paged() ) {
            $author = get_query_var( 'author' );

            // Don't 404 for authors without posts as long as they matched an author on this site.             if ( is_author() && is_numeric( $author ) && $author > 0 && is_user_member_of_blog( $author )
                // Don't 404 for these queries if they matched an object.                 || ( is_tag() || is_category() || is_tax() || is_post_type_archive() ) && get_queried_object()
                // Don't 404 for these queries either.                 || is_home() || is_search() || is_feed()
            ) {
                $set_404 = false;
            }
        }

        if ( $set_404 ) {
            // Guess it's time to 404.             $wp_query->set_404();
            status_header( 404 );
            
Home | Imprint | This part of the site doesn't use cookies.