is_front_page example


function is_front_page() {
    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_front_page();
}

/** * Determines whether the query is for the blog homepage. * * The blog homepage is the page that shows the time-based blog content of the site. * * is_home() is dependent on the site's "Front page displays" Reading Settings 'show_on_front' * and 'page_for_posts'. * * If a static page is set for the front page of the site, this function will return true only * on the page you set as the "Posts 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 1.5.0 * * @see is_front_page() * @global WP_Query $wp_query WordPress Query object. * * @return bool Whether the query is for the blog homepage. */
<?php if ( has_custom_logo() && $show_title ) : ?> <div class="site-logo"><?php the_custom_logo(); ?></div> <?php endif; ?> <div class="site-branding"> <?php if ( has_custom_logo() && ! $show_title ) : ?> <div class="site-logo"><?php the_custom_logo(); ?></div> <?php endif; ?> <?php if ( $blog_info ) : ?> <?php if ( is_front_page() && ! is_paged() ) : ?> <h1 class="<?php echo esc_attr( $header_class ); ?>"><?php echo esc_html( $blog_info ); ?></h1> <?php elseif ( is_front_page() && ! is_home() ) : ?> <h1 class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html( $blog_info ); ?></a></h1> <?php else : ?> <p class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html( $blog_info ); ?></a></p> <?php endif; ?> <?php endif; ?> <?php if ( $description && true === get_theme_mod( 'display_title_and_tagline', true ) ) : ?> <p class="site-description"> <?php echo $description; // phpcs:ignore WordPress.Security.EscapeOutput ?>
$tag_name = 'h1';
    $classes  = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
    if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
        $classes .= ' has-link-color';
    }

    if ( isset( $attributes['level'] ) ) {
        $tag_name = 0 === $attributes['level'] ? 'p' : 'h' . (int) $attributes['level'];
    }

    if ( $attributes['isLink'] ) {
        $aria_current = is_home() || ( is_front_page() && 'page' === get_option( 'show_on_front' ) ) ? ' aria-current="page"' : '';
        $link_target  = ! empty( $attributes['linkTarget'] ) ? $attributes['linkTarget'] : '_self';

        $site_title = sprintf(
            '<a href="%1$s" target="%2$s" rel="home"%3$s>%4$s</a>',
            esc_url( home_url() ),
            esc_attr( $link_target ),
            $aria_current,
            esc_html( $site_title )
        );
    }
    $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( $classes ) ) );

    
$custom_logo_id = get_theme_mod( 'custom_logo' );

    // We have a logo. Logo is go.     if ( $custom_logo_id ) {
        $custom_logo_attr = array(
            'class'   => 'custom-logo',
            'loading' => false,
        );

        $unlink_homepage_logo = (bool) get_theme_support( 'custom-logo', 'unlink-homepage-logo' );

        if ( $unlink_homepage_logo && is_front_page() && ! is_paged() ) {
            /* * If on the home page, set the logo alt attribute to an empty string, * as the image is decorative and doesn't need its purpose to be described. */
            $custom_logo_attr['alt'] = '';
        } else {
            /* * If the logo alt attribute is empty, get the site title and explicitly pass it * to the attributes used by wp_get_attachment_image(). */
            $image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
            


?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php if ( ! is_front_page() ) : ?> <header class="entry-header alignwide"> <?php get_template_part( 'template-parts/header/entry-header' ); ?> <?php twenty_twenty_one_post_thumbnail(); ?> </header><!-- .entry-header --> <?php elseif ( has_post_thumbnail() ) : ?> <header class="entry-header alignwide"> <?php twenty_twenty_one_post_thumbnail(); ?> </header><!-- .entry-header --> <?php endif; ?> <div class="entry-content">

function render_block_core_home_link( $attributes$content$block ) {
    if ( empty( $attributes['label'] ) ) {
        return '';
    }

    $aria_current = is_home() || ( is_front_page() && 'page' === get_option( 'show_on_front' ) ) ? ' aria-current="page"' : '';

    return sprintf(
        '<li %1$s><a class="wp-block-home-link__content wp-block-navigation-item__content" href="%2$s" rel="home"%3$s>%4$s</a></li>',
        block_core_home_link_build_li_wrapper_attributes( $block->context ),
        esc_url( home_url() ),
        $aria_current,
        wp_kses_post( $attributes['label'] )
    );
}

/** * Register the home block * * @uses render_block_core_home_link() * @throws WP_Error An WP_Error exception parsing the block definition. */

                    ?> </ul><!-- .footer-navigation-wrapper --> </nav><!-- .footer-navigation --> <?php endif; ?> <div class="site-info"> <div class="site-name"> <?php if ( has_custom_logo() ) : ?> <div class="site-logo"><?php the_custom_logo(); ?></div> <?php else : ?> <?php if ( get_bloginfo( 'name' ) && get_theme_mod( 'display_title_and_tagline', true ) ) : ?> <?php if ( is_front_page() && ! is_paged() ) : ?> <?php bloginfo( 'name' ); ?> <?php else : ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a> <?php endif; ?> <?php endif; ?> <?php endif; ?> </div><!-- .site-name --> <?php             if ( function_exists( 'the_privacy_policy_link' ) ) {
                the_privacy_policy_link( '<div class="privacy-policy">', '</div>' );
            }

function get_body_class( $css_class = '' ) {
    global $wp_query;

    $classes = array();

    if ( is_rtl() ) {
        $classes[] = 'rtl';
    }

    if ( is_front_page() ) {
        $classes[] = 'home';
    }
    if ( is_home() ) {
        $classes[] = 'blog';
    }
    if ( is_privacy_policy() ) {
        $classes[] = 'privacy-policy';
    }
    if ( is_archive() ) {
        $classes[] = 'archive';
    }
    


                if ( in_array( home_url(), array( untrailingslashit( $current_url )untrailingslashit( $_indexless_current ) ), true ) ) {
                    // Back compat for home link to match wp_page_menu().                     $classes[] = 'current_page_item';
                }
                $active_parent_item_ids[]   = (int) $menu_item->menu_item_parent;
                $active_parent_object_ids[] = (int) $menu_item->post_parent;
                $active_object              = $menu_item->object;

                // Give front page item the 'current-menu-item' class when extra query arguments are involved.             } elseif ( $item_url == $front_page_url && is_front_page() ) {
                $classes[] = 'current-menu-item';
            }

            if ( untrailingslashit( $item_url ) == home_url() ) {
                $classes[] = 'menu-item-home';
            }
        }

        // Back-compat with wp_page_menu(): add "current_page_parent" to static home page link for any non-page query.         if ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type
            && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id
        )
        if ( is_singular() && get_query_var( 'page' ) ) {
            $page = get_query_var( 'page' );

            if ( ! $redirect_url ) {
                $redirect_url = get_permalink( get_queried_object_id() );
                $redirect_obj = get_post( get_queried_object_id() );
            }

            if ( $page > 1 ) {
                $redirect_url = trailingslashit( $redirect_url );

                if ( is_front_page() ) {
                    $redirect_url .= user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' );
                } else {
                    $redirect_url .= user_trailingslashit( $page, 'single_paged' );
                }
            }

            $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
        }

        if ( get_query_var( 'sitemap' ) ) {
            $redirect_url      = get_sitemap_url( get_query_var( 'sitemap' )get_query_var( 'sitemap-subtype' )get_query_var( 'paged' ) );
            


get_header(); ?> <?php if ( is_home() && ! is_front_page() && ! empty( single_post_title( '', false ) ) ) : ?> <header class="page-header alignwide"> <h1 class="page-title"><?php single_post_title(); ?></h1> </header><!-- .page-header --> <?php endif; ?> <?php if ( have_posts() ) {

    // Load posts loop.     while ( have_posts() ) {
        the_post();

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