Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
the page itself dont have text - growingedgecoaching.com/home how could wordpress generate the excerpt from that? Have you added text in editor while doing post ? –  amit Jul 30 '12 at 23:20
    
I've corrected the link to the correct page- growingedgecoaching.com/blog The problem persists. –  user1255049 Jul 31 '12 at 0:38
    
Why do you close and re-open the PHP context on each line? That’s not necessary. –  toscho Jul 31 '12 at 6:04
    
solved? right now, the link /blog/ shows thumbnails and excerpts; if not solved, please paste the full code of the template into a pastebin –  Michael Jul 31 '12 at 11:45

1 Answer 1

up vote 2 down vote accepted
<?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.

share|improve this answer
    
Amit, thank you again for the help. We are getting closer to being correct. If you visit the site now, it simply links to "Landing," instead of displaying post excerpts. Any ideas on why that may be? –  user1255049 Jul 31 '12 at 0:37
    
I found the excerpt of first post is showing up on landing page, but the title and link is different.. please, provide us the full code of your landing page using pastebin.com –  amit Aug 1 '12 at 7:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.