the_excerpt showing the whole post (3 posts)

  1. jonohale
    Posted 3 years ago #

    Hey there,

    I've got a theme i'm developing and we had the_excerpt working correctly and when i went back to work on some more code it appears to have stopped working. It shows the whole post.

    Here is the code in the theme file:

    <?php query_posts('cat=27&showposts=1'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div id="block-weather_watch_extras-0" class="block ">
            <h2 class="title"><a href="<?php the_permalink(); ?>">
              <?php the_title(); ?>
              </a>  </h2>
              <a href="<?php the_permalink(); ?>"><?php
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    } ?></a>
    <?php the_content('<br /><br /><span class="readmore-icon">Read the rest of '. get_the_title($post->ID). '</span>', TRUE);?>
            <?php endwhile; endif; ?>

    and this one is in the functions file.

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

    Thanks for your help :)

  2. PremiumWP
    Posted 3 years ago #

    In your theme file you are using 'the_content' rather than 'the_excerpt' hence the reason it’s showing the full post. See more about the_excerpt function here http://codex.wordpress.org/Function_Reference/the_excerpt

  3. jonohale
    Posted 3 years ago #

    Thanks for that, I accidentally copied the wrong code... was part of testing, it does have the excerpt one in the site causing the error.



Topic Closed

This topic has been closed to new replies.

About this Topic