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 am having a problem with the the_excerpt(); tag which I am using in my own theme in the index.php and archive.php files. The code is below:

index.php

<?php get_header(); ?>
<section class="center-column">
<?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
     <!--<?php echo the_permalink(); ?>-->
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <header>
            <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
            <div class="post-date"><?php the_time(get_option( 'date_format' )); ?></div>
        </header>
        <?php the_excerpt(); ?>
        <footer class="post-footer">
            <div class="categories">Posted in: <?php the_category(', '); ?></div>
            <div class="tags">Tags: <?php the_tags(); ?></div>
        </footer>
    </article>
    <?php endwhile; ?>
    <section class="post-navigation">
        <div class="alignleft">
            <?php next_posts_link('&laquo; Older Entries') ?>
        </div>
        <div class="alignright">
            <?php previous_posts_link('Newer Entries &raquo;') ?>
        </div>
    </section>
<?php else : ?>
    <article>
        <h3>Not Found</h3>
        <p>Sorry, but you are looking for something that is not available</p>
    </article>
<?php endif; ?>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

archive.php

<?php get_header(); ?>

<section class="center-column">
    <!-- Archive Heading -->
    <section>
        <h3 id='archive-heading'>
            <?php if (is_category()) { ?>
            Archive for the '<?php single_cat_title(); ?>' Category
            <?php } elseif (is_tag()) { ?>
            Posts Tagged '<?php single_tag_title(); ?>'
            <?php } elseif (is_month()) { ?>
            Archive for <?php echo get_the_date('F Y'); ?>
            <?php } ?>
        </h3>
    </section>
    <!-- End Archive Heading -->

    <!-- Post Excerpt -->
    <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
            <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <header>
                    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                    <div class="post-date"><?php the_time(get_option( 'date_format' )); ?></div>
                </header>
                <?php the_excerpt(); ?>
                <footer>
                    <div class="categories">Posted in:
                        <?php the_category(', '); ?>
                    </div>
                    <div class="tags">Tags:
                        <?php the_tags(); ?>
                    </div>
                </footer>
            </article>
        <?php endwhile; ?>
    <?php endif; ?>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Sorry for the long pieces of code.

I am not sure exactly where the problem lies and would be grateful for any help you can provide.

Many thanks, nav

share|improve this question
2  
So what's the actual problem? Excerpt not showing? –  onetrickpony Apr 4 '12 at 18:20
    
are you sure the page you're viewing is actually using the templates you think it's using, that could explain it. Personally I add echo "index.php"; at the top or bottom of the index.php and same with other templates during development just so I can be sure. –  byronyasgur Apr 4 '12 at 18:21
    
Are you running any plugins? –  m0r7if3r Apr 4 '12 at 18:35
1  
Two questions: 1) What do you have set as "page for posts" and "front page" in Dashboard -> Settings -> Reading? And 2) Do you have a home.php template file defined? Your body classes aren't outputting properly on the URL you linked, but they are outputting properly on your front page, and on your single blog post. –  Chip Bennett Apr 4 '12 at 19:35
1  
How did you migrate the site from dev to production? –  Chip Bennett Apr 4 '12 at 19:54
show 10 more comments

1 Answer

up vote 1 down vote accepted

Thank you for all your help, especially @byronyasgur for your last suggestion. It helped me fix it.

I was using markdown as the input format for the content, and the first line was HTML comment which was not followed by a blank line. Adding a blank line fixed it.

Summary: The absence of this line caused the excerpt to be null. This blnak line did exist in my development system but not on the live system.

Markdown users beware of the need of blank lines.

Sorry for the noise.

share|improve this answer
add comment

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.