has_category example


function in_category( $category$post = null ) {
    if ( empty( $category ) ) {
        return false;
    }

    return has_category( $category$post );
}

/** * Displays category list for a post in either HTML list or custom format. * * @since 0.71 * * @param string $separator Optional. Separator between the categories. By default, the links are placed * in an unordered list. An empty string will result in the default behavior. * @param string $parents Optional. How to display the parents. Accepts 'multiple', 'single', or empty. * Default empty string. * @param int $post_id Optional. ID of the post to retrieve categories for. Defaults to the current post. */
// Edit post link.             edit_post_link(
                sprintf(
                    /* translators: %s: Post title. Only visible to screen readers. */
                    esc_html__( 'Edit %s', 'twentytwentyone' ),
                    '<span class="screen-reader-text">' . get_the_title() . '</span>'
                ),
                '<span class="edit-link">',
                '</span><br>'
            );

            if ( has_category() || has_tag() ) {

                echo '<div class="post-taxonomies">';

                $categories_list = get_the_category_list( wp_get_list_item_separator() );
                if ( $categories_list ) {
                    printf(
                        /* translators: %s: List of categories. */
                        '<span class="cat-links">' . esc_html__( 'Categorized as %s', 'twentytwentyone' ) . ' </span>',
                        $categories_list // phpcs:ignore WordPress.Security.EscapeOutput                     );
                }

                
Home | Imprint | This part of the site doesn't use cookies.