I see the following code a lot in index.php files. I understand that is_front_page()
returns true when viewing the Site Front Page (whether displaying the blog posts index or a static page), while is_home()
returns true when viewing the Blog Posts Index (whether displayed on the front page or on a static page). I am still somewhat stumped about the use of the following code -
<?php if ( have_posts() ) : ?>
<?php if ( is_home() && ! is_front_page() ) : ?>
<header>
<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
</header>
<?php endif; ?>
Any explanation of why this piece of code is so popular is greatly appreciated.