I am a new to WordPress. My site is running WordPress 3.2 with the TwentyEleven theme. I wanted to change the way posts under archives and categories are displayed. Instead of listing all the posts, I want to list the title of the post and a summary. This post describes the simple changes that need to be done to the TwentyEleven theme to accomplish this change in functionality.
Visit ThemeFm for a good overview of the TwentyEleven theme. The content.php page, which is the page with the default template to display all post, has logic to display the summary of the post when it is displayed in a search. That’s exactly what I want to do when displaying the list of posts in a category or in an archive. Step 1, is to make a copy of the content.php template and to name it content-archive.php.
Step 2, requires minor modifications to the content-archive.php page. Look for the following code in the content-archive.php.
?php if ( is_search() ) : // Only display Excerpts for Search ?> <div> <?php the_excerpt(); ?> </div><!-- .entry-summary --> <?php else : ?> <div> <?php the_content( __( 'Continue reading <span>&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;rarr;</span>', 'twentyeleven' ) ); ?> <?php wp_link_pages( array( 'before' => '<div><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?> </div><!-- .entry-content --> <?php endif; ?>
Replace this block of code for the following code in order to force the the template to behave as in search mode.
<?php // display Excerpts for archive ?> <div> <?php the_excerpt(); ?> </div><!-- .entry-summary -->
At this point we have a template that displays the title of the post with date information and the summary. Step 3, requires linking the content-archive template to the archive and category display. Open the Category Template (category.php) and replace the following code
get_template_part( 'content', get_post_format() );
with the following line in order to link the content-archive to the category display.
get_template_part( 'content', 'archive' );
Repeat the same step for the Archive Template (archive.php) and that’s it, you are done. Settings->Reading allows you to control how many posts to list per page.