Support » Fixing WordPress » Recent posts on homepage showing full post not excerpt

  • I have managed to get recent posts showing on my homepage which is working well. They only problem i have is that the full post and not the excerpt is showing.

    <div id="home-news-container">
    <?php query_posts('cat=#&posts_per_page=3'); ?>
    <?php while (have_posts()) : the_post(); ?>
        <div class="home-post-container">
              <div class="home-post-thumb">
                  <a href="<?php echo get_permalink(); ?>">
                            <?php the_post_thumbnail('large_wide'); ?>
              <div class="home-post-copy">
                          <a href="<?php echo get_permalink(); ?>">
                               <?php the_title(); ?>
                          <?php the_date(); ?>
                  <?php the_excerpt(); ?>
                  <div class="home-news-readmore">
                        <a href="<?php echo get_permalink(); ?>">read more</a>
       </div> <!-- end home-post-container -->
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>
              <div class="home-news-readmore news-extra">
                   <a href="">more news</a>
    </div> <!--- end home-post-container -->

    I don’t understand what the problem is to be honest. I created a new full width template for the homepage which i thought might be causing it but its not. Bit stumped to be honest. Any help would be greatly appreciated

Viewing 3 replies - 1 through 3 (of 3 total)
  • You have an issue with this line:

    <?php query_posts('cat=#&posts_per_page=3'); ?>

    You are not using a valid “cat” value. Either enter a category number, like this (if category id 8 was desired):

    <?php query_posts(array('cat' => '8', 'posts_per_page' => '3'); ?>

    Or, remove the “cat” value altogether:

    <?php query_posts('posts_per_page=3'); ?>

    Good point, I don’t need a category so i removed it. Unfortunately it hasn’t made any difference

    I managed to fix it using this code instead of the_excerpt

    $content = get_the_excerpt();
    echo wp_trim_words( $content , '30' ); ?>

    incase anyone else has this issue

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Recent posts on homepage showing full post not excerpt’ is closed to new replies.