the_excerpt not showing posts

I’m using the following code to show the single most recent post on my landing page:

<?php if (have_posts()) : ?>
<?php if (($wp_query->post_count) > 1) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_excerpt() ?>
<?php endwhile; ?>

<?php else : ?>

<?php while (have_posts()) : the_post(); ?>
<?php the_excerpt() ?>
<?php endwhile; ?>
<?php endif; ?>

<?php else : ?>
<p>Nothing to see here.</p>

<?php endif; ?>

My problem is the code doesn’t seem to be producing an excerpt. What could be the problem?

Related posts

Leave a Reply

1 comment

  1. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        <?php the_excerpt() ?>
    <?php endwhile; else: ?>
        <p>Nothing to see here.</p>
    <?php endif; ?>
    

    This is the right syntax to show title and the excerpt on home page.