How to make category pages display post excerpts

Category pages, just like search results or archives, are usually used for navigation purposes. Considering this fact it would make no sense to display full posts on those pages since the reader needs to be able to skim through a larger number of posts to decide what he wants to read.

If your Wordpress theme is currently displaying full posts on the category or archive pages below you will find how to change it, showing only the post excerpts or even the post titles.

First of all you need to locate the file inside your theme folder that is managing the category, archives and search pages. Most Wordpress themes have that information inside the archive.php or archives.php file.

The file will look more or less like this:

<?php if (is_category()) { ?>
<h2 class='archives'>Archive for the '<?php echo single_cat_title(); ?>' Category</h2>
<?php }
elseif (is_day()) { ?>
<h2 class='archives'>Archive for <?php the_time('F jS, Y'); ?></h2>

Once you find the file you will need to find where the Loop starts, usually with the following line:

<?php while (have_posts()) : the_post(); ?>

The information contained inside the Loop will govern the structure of the posts inside the mentioned pages (categories, archives, search results and so on). A couple of lines after the beginning of the Loop you will find the argument that includes the full posts on those pages:

<?php the_content(__('Read more »'));?>

In order to display the post excerpts you will need to substitute that line with the following:

<?php the_excerpt() ?>

If you want to display only the post titles (should be considered if you have a large number of posts on every category or on the archives) you can just eliminate that line altogether.

Finally, you may also want to remove the meta data (author, date or comments information) from those pages, which should be listed right after the post title or after the content line.

Got the Daily Blog Tips Newsletter?

  • Tips and tricks to improve your site
  • The latest trends and opportunities
  • Useful online tools
  • It's free!

28 Responses to “How to make category pages display post excerpts”

  1. Rory on March 2nd, 2007 6:05 am

    Brilliant. Thank you for this.

    I wish I could convey how hard I’m kicking myself for not voting for you in those recent Web Awards. I didn’t vote for anyone, but I’m cursing now!

  2. Daniel on March 2nd, 2007 6:07 am

    I voted for Problogger.net myself, so no big deal :)

  3. Madhur Kapoor on March 2nd, 2007 6:14 am

    Very nice tip Daniel .

  4. Rory on March 2nd, 2007 6:27 am

    I hit a roadblock straight away - I don’t have an archives.php!

    I have it in my themes folder, but it is not available on the Presentation page. Is it because I removed it from my sidebar?

    My (hidden) archives.php reads:

    Archives
    By month:

    By category:

    But I’m not sure if I edit that it will make any difference.

  5. Daniel on March 2nd, 2007 6:34 am

    Rory, lets chat via Skype, the file must be there somewhere otherwise the category pages would not be loading hehe.

  6. engtech on March 2nd, 2007 10:13 am

    Excerpts are a great practice. Here’s a good article on them:

    http://www.pearsonified.com/20.....y-step.php

    One thing I’ve noticed is that if you’re using a feedburner feed with summaries it’ll use your excerpt instead of just cutting off the first 200 characters or so.

  7. Thilak on March 2nd, 2007 11:09 pm

    Sweet Hack! I really hate to see long posts in archives. I use a plugin called Evenmore, which does this automatically

  8. Ajay on March 4th, 2007 3:07 am

    Daniel, you should mention that a category.php in the theme is the best way to create the category pages. Alternatively, you can use the (is_category()) and if true display the_excerpt otherwise do the_content

  9. Rich on June 19th, 2007 5:08 pm

    Excellent info. I found myself in the same boat as Rory in that the theme I use (Burvy from GFX) did not have separate calls for archives and categories. I’m not an expert, but it seems my theme uses the same post output whether it is single post, archive, or category selected. I tried to carve out an excerpt call in the index.php just for category pages with the info you give but I couldn’t get it to work.

    I was curious if a workaround was discovered for these situations when you worked with Rory?

  10. Daniel on June 20th, 2007 7:28 am

    Rich, at the very least I think your theme has on call for single posts and one for archives, categories and search results, could it be?

    If that is not in place you will need to create those manually on the theme files. Just check some themes that use that structure and replicate it.

  11. Andrew Swihart on July 24th, 2007 12:46 pm

    Glad I use Textpattern so I never have to deal with an issue like this where you actually have to know some php to do such a simple thing.

  12. liuxxir on August 13th, 2007 11:24 pm

    prevedburzhuy

  13. dave on October 12th, 2007 4:54 am

    Just a quick question….. how do you change the [...] at the end of the excerpt to “read more” or “see more” or anything instead of [...] ?
    dave

  14. dave on October 12th, 2007 11:16 am

    never mind…. i just found this really great plugin which does everything i want and more!

  15. dave on October 12th, 2007 11:17 am

    oops forgot to list the plugin for whoever might be interested…
    http://guff.szub.net/2005/02/2.....-reloaded/

    the only thing is you need to get into code a wee bit…..

  16. PeterVk on February 6th, 2008 7:20 pm

    Thanks! Tip worked like a charm.

  17. I V Y O L O G Y on May 13th, 2008 7:30 am

    Oh my god, THANK YOU!!! I was told I have to install a plugin and fiddle with this and that, but no! I don’t! Thank you SO much for the simple instructions, you rock.

  18. Bang Kritikus on January 28th, 2009 4:06 am

    Thanks for your guides

  19. Masdin on March 15th, 2009 4:32 am

    Thank you very much for sharing

    It works well in my wordpress theme (Inove).

  20. Adam Pieniazek on March 23rd, 2009 4:50 am

    Is there a way to include the read more link dave was talking about on excerpts without fuddling about with the tag?

  21. Adam Pieniazek on March 23rd, 2009 4:53 am

    Nevermind, got it. Simply place the below code after the excerpt code:

    “<a href=”" rel=”bookmark”>Read more“

  22. Adam Pieniazek on March 23rd, 2009 4:56 am

    That code did not come through correct:

    a href=”?php the_permalink() ?>” rel=”bookmark”>Read the full post</a

    add an open bracket < at the start and before the first question mark, also add an end bracket at the end.

  23. CreativeUnit on May 28th, 2009 5:46 pm

    Thank you for posting this!!!

Got something to say?





Sponsors

Why I recommend Doreo Hosting Flex Theme for WordPress Content rich web directory Ghost Writing Services Online Invoicing For Freelancers advertise here

Recent Articles