is_category example

/** * 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. */
<li> <?php get_search_form(); ?> </li> <!-- Author information is disabled per default. Uncomment and fill in your details if you want to use it. <li><h2><?php _e( 'Author' ); ?></h2> <p>A little something about you, the author. Nothing lengthy, just an overview.</p> </li> --> <?php                 if ( is_404() || is_category() || is_day() || is_month() ||
                is_year() || is_search() || is_paged() ) :
                    ?> <li> <?php if ( is_404() ) : /* If this is a 404 page */ ?> <?php elseif ( is_category() ) : /* If this is a category archive */ ?> <p> <?php                     printf(
                        /* translators: %s: Category name. */
                        __( 'You are currently browsing the archives for the %s category.' ),
                        
    } 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' ) );

    }

function is_category( $category = '' ) {
    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_category( $category );
}

/** * Determines whether the query is 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. * * 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.3.0 * * @global WP_Query $wp_query WordPress Query object. * * @param int|string|int[]|string[] $tag Optional. Tag ID, name, slug, or array of such * to check against. Default empty. * @return bool Whether the query is for an existing tag archive page. */
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 );
            
/** * 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 ( is_array( $post_type ) ) {
                $post_type = reset( $post_type );
            }
            $classes[] = 'post-type-archive-' . sanitize_html_class( $post_type );
        } elseif ( is_author() ) {
            $author    = $wp_query->get_queried_object();
            $classes[] = 'author';
            if ( isset( $author->user_nicename ) ) {
                $classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID );
                $classes[] = 'author-' . $author->ID;
            }
        } elseif ( is_category() ) {
            $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;
            }
        }
'class'             => 'postform',
        'depth'             => 0,
        'tab_index'         => 0,
        'taxonomy'          => 'category',
        'hide_if_empty'     => false,
        'option_none_value' => -1,
        'value_field'       => 'term_id',
        'required'          => false,
        'aria_describedby'  => '',
    );

    $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;

    // Back compat.     if ( isset( $args['type'] ) && 'link' === $args['type'] ) {
        _deprecated_argument(
            __FUNCTION__,
            '3.0.0',
            sprintf(
                /* translators: 1: "type => link", 2: "taxonomy => link_category" */
                __( '%1$s is deprecated. Use %2$s instead.' ),
                '<code>type => link</code>',
                '<code>taxonomy => link_category</code>'
            )
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 ) ) {
                
Home | Imprint | This part of the site doesn't use cookies.