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>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?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/
Thanks
I actually solved it myself, it turns out there was this piece of code which I removed that solved my problem:
Not sure what it does though, but it doesn’t seem like I need it.
The function that gets the excerpt, and
the_excerpt
itself, can be located inwp-includes/post-template.php
. It looks like this:Corresponding to
the_content
there is aget_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 thepost_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
orthe_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.