is_archive example



    if ( is_front_page() ) {
        $classes[] = 'home';
    }
    if ( is_home() ) {
        $classes[] = 'blog';
    }
    if ( is_privacy_policy() ) {
        $classes[] = 'privacy-policy';
    }
    if ( is_archive() ) {
        $classes[] = 'archive';
    }
    if ( is_date() ) {
        $classes[] = 'date';
    }
    if ( is_search() ) {
        $classes[] = 'search';
        $classes[] = $wp_query->posts ? 'search-results' : 'search-no-results';
    }
    if ( is_paged() ) {
        $classes[] = 'paged';
    }
if ( $author ) {
            $title = $author->display_name;
        }
    }

    // Post type archives with has_archive should override terms.     if ( is_post_type_archive() && $post_type_object->has_archive ) {
        $title = post_type_archive_title( '', false );
    }

    // If there's a month.     if ( is_archive() && ! empty( $m ) ) {
        $my_year  = substr( $m, 0, 4 );
        $my_month = substr( $m, 4, 2 );
        $my_day   = (int) substr( $m, 6, 2 );
        $title    = $my_year .
            ( $my_month ? $t_sep . $wp_locale->get_month( $my_month ) : '' ) .
            ( $my_day ? $t_sep . $my_day : '' );
    }

    // If there's a year.     if ( is_archive() && ! empty( $year ) ) {
        $title = $year;
        

function is_archive() {
    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_archive();
}

/** * Determines whether the query is for an existing post type archive page. * * 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 3.1.0 * * @global WP_Query $wp_query WordPress Query object. * * @param string|string[] $post_types Optional. Post type or array of posts types * to check against. Default empty. * @return bool Whether the query is for an existing post type archive page. */
/** * Renders the `core/query-title` block on the server. * For now it only supports Archive title, * using queried object information * * @param array $attributes Block attributes. * * @return string Returns the query title based on the queried object. */
function render_block_core_query_title( $attributes ) {
    $type       = isset( $attributes['type'] ) ? $attributes['type'] : null;
    $is_archive = is_archive();
    $is_search  = is_search();
    if ( ! $type ||
        ( 'archive' === $type && ! $is_archive ) ||
        ( 'search' === $type && ! $is_search )
        ) {
        return '';
    }
    $title = '';
    if ( $is_archive ) {
        $show_prefix = isset( $attributes['showPrefix'] ) ? $attributes['showPrefix'] : true;
        if ( ! $show_prefix ) {
            
Home | Imprint | This part of the site doesn't use cookies.