On WordPress, I have a small block displaying the most recent posts within the common footer of my site. I want to be able to only show the excepts on the front page, and hide these excepts (showing only the post title) on any other page that uses this common footer.
Here is my working code:
<?php while ( have_posts() ) : the_post(); ?>
<div class="large-6 columns footer-news-title">
<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<section class="entry-header">
<h5><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h5>
</section>
<section class="entry-content">
<?php the_excerpt(); ?>
</section>
</article>
</div>
<?php endwhile; ?>
I’ve used an “If Frontpage” loop in the header, so I thought I should wrap the entry-content section with the “If” code I used before:
<?php if( is_front_page() ) : ?>
<section class="entry-content">
<?php the_excerpt(); ?>
</section>
<?php endif;?>
However, this didn’t work. When I wrap the code like above, I get no excerpts on any page. When I change “is_front_page” to “is_home” or “is_home_page” I get excerpts on all pages.
I’ve spent time this morning searching around but all I can find are instructions on the use of “If” statements or “While” statement, but nothing on using an “If” inside of a “while” on WordPress.
Any ideas? Thanks for the help beforehand.
What is the name you gave to your front page when creating the page in WordPress admin?
Try:
Combine both home and front page conditions like so: