WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the latest WordPress version and when I use <?php the_excerpt(); ?> on the index page it doesn't show the post excerpt.

I tried putting in the_content() instead and it worked, so I'm assuming there is something wrong.

My code:

<?php get_header(); ?>

<?php if (have_posts()) : ?>
<div id="post-area">
<?php while (have_posts()) : the_post(); ?> 

        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
         <?php if ( has_post_thumbnail() ) { ?>
         <div class="gridly-image"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail( 'summary-image' );  ?></a></div>
          <div class="gridly-category"><p><?php the_category(', ') ?></p></div>

          <?php } ?>
                <div class="gridly-copy"><h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
                <p class="gridly-date"><?php the_time(get_option('date_format')); ?>  </p>

            <p class="gridly-excerpt"><?php the_excerpt(); ?></p>
            <div class="read-more">
                <a class="read-more-button" title="Read More" href="<?php the_permalink() ?>">Read More</a>

<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>

<?php next_posts_link('<p class="view-older">View Older Entries</p>') ?>

<?php get_footer(); ?>

I am using this theme: http://www.eleventhemes.com/gridly-theme/


share|improve this question

migrated from stackoverflow.com Mar 4 '13 at 13:15

This question came from our site for professional and enthusiast programmers.

Are you inside the loop with this? Where exactly are you calling the function, can you show some code? – Pekka 웃 Mar 2 '13 at 19:15
It is very hard to look at the issue without the code that actually calls the excerpt. – Marco Berrocal Mar 2 '13 at 19:19
This is in the loop, I will update the post to show my code. Where can I find the original the_excerpt() function ? – CodexVideos Mar 2 '13 at 19:23

The function that gets the excerpt, and the_excerpt itself, can be located in wp-includes/post-template.php. It looks like this:

function get_the_excerpt( $deprecated = '' ) {
        if ( !empty( $deprecated ) )
                _deprecated_argument( __FUNCTION__, '2.3' );

        $post = get_post();

        if ( post_password_required() ) {
                return __( 'There is no excerpt because this is a protected post.' );

        return apply_filters( 'get_the_excerpt', $post->post_excerpt );

Corresponding to the_content there is a get_the_content which retrieves the post and the post content in the same way. So if one works and the other doesn't, this indicates that there simply isn't any except? Have you double checked that there really is an excerpt for the post? Did you check the post_except field in the database?

If you do that, and it looks like there should be an excerpt to display, the only possible explanation is that you have a function hooked to either get_the_excerpt or the_excerpt that returns nothing. So you have to locate the code that does that. If you are familiar with such tools, you could search for any occurrence of said hooks in your plugins and theme. If you're not, you may want to try to disable the plugins one by one and maybe trying a different theme.

share|improve this answer
up vote 0 down vote accepted

I actually solved it myself, it turns out there was this piece of code which I removed that solved my problem:

    function custom_excerpt_length( $length ) {
        return 0;
    add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

Not sure what it does though, but it doesn't seem like I need it.

share|improve this answer
This piece of code set the length of your excerpt to 0... which is why you didn't get anything when calling the_excerpt() – fkoessler Aug 11 '13 at 3:02

Your Answer


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.