Claudio Delgado
Claudio Delgado

Reputation: 2349

My new Wordpress theme works perfectly except I don't know how to limit the blog posts shown in the blog page

My theme supports pages, posts and blog category pages but my assigned blog page doesn't limit anything, it shows all posts no matter what. I've already set the blog page to show only 5 latest posts.

I just want it to show an excerpt of the blog posts with a 'Read more...' link in the bottom.

How do I only show excerpts of posts in the blog page?

Current template:

    <div id="contentMain">
    <div class="left-section">
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <div class="body-top"></div>
    <div class="entry-content body-content">
    <?php 
    if (is_page()) {
    echo '';    
    }
    if ((is_single()) || (is_home())) {
    echo '<h2 class="entry-title">'; the_title(); '</h2>';
    }
    ?>
    <?php 
    if (is_page()) {
    the_content();  
    }
    if ((is_single()) || (is_home())) {
    echo '<h6>'; the_content(); '</h6>';
    echo '<hr />';
    }
    ?>           
    <?php  ?>                 
    </div>
    <div class="body-bottom"></div>
    </div>

    <?php endwhile; ?>
    </div>
    </div>
     </div>
     <?php get_footer(); ?>

Upvotes: 0

Views: 97

Answers (2)

ben author
ben author

Reputation: 2955

Use the_excerpt() where you want an excerpt to show up rather than the_content(). So something like

<?php if (is_home()) {
    the_excerpt();
} else {
    the_content();
} ?>

Upvotes: 2

thenetimp
thenetimp

Reputation: 9820

Change this

if ((is_single()) || (is_home())) {
  echo '<h6>'; the_content(); '</h6>';
  echo '<hr />';
}

to this

if ((is_single())) {
  echo '<h6>'; the_content(); '</h6>';
  echo '<hr />';
}
if ((is_home())) {
  echo '<h6>'; the_content(); '</h6>';
  echo '<hr />';
}

That should fix what you are experiencing

Upvotes: 0

Related Questions