Many WordPress themes are setup to display their category pages in the same format as your blog’s homepage, making your categories useless to some. This can cause duplicate content problems, as well as making your categories difficult to avoid. If this isn’t the case for you, then your theme is probably instead setup to just display a post excerpt for each post on your category page. I’ve never been a fan of this either, as this format strips your post of links/styles and doesn’t give you control over how much of the post to display.
Instead, I’ve always liked the idea of showing only the post titles on your category pages. If you are good at making post titles, this should help someone navigating your categories to find what they are looking for.
First, you’ll want to open your archive.php file and find the post loop. It usually starts with this code (or something similar):
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
You’ll want to delete everything from that code down to the end of the loop, which usually ends with this:
<?php endif; ?>
Now, you’ll want to replace the post loop code with the following slightly different code loop:
<?php $temp_category = single_cat_title('',false); if (!empty($temp_category)){ // give index ?>
<h1><?php single_cat_title(); ?></h1>
<p><?php echo(category_description(the_category_ID(false))); ?></p>
<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li><br>
<?php endforeach; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php }else{ // give details or single post ?>
...... code for normal post overview
<?php } ?>
And you’re done! You can add<li>, <ol>, and whatever else as needed, and then style your archives page in your stylesheet to get the look you’re trying to achieve.












Monday, March 24th, 2008 at 2:15 pm
Just wanted to let you know that the code blocks on this post did not come through on my RSS feed.
Monday, March 24th, 2008 at 3:14 pm
Kyle,
I’ve seen the “title only” approach in use around the blogosphere and have been considering going that route. But…
What do you think about including the “Optional Excerpt” below the title if kept to a limited amount of text? Perhaps even different text than the post itself?
Monday, March 24th, 2008 at 3:53 pm
THANK YOU! I’ve noticed something similar on the premium themes and have wondered how to do this. This is great!
Monday, March 24th, 2008 at 8:01 pm
@ Ken - Thanks for the heads up on this. What feed reader are you using? I’ve checked in 3 different readers and the code showed up fine.
@ Richard - I’m okay with that. I think it is really a preference thing. As long as you aren’t using full posts you should be good to go. On some sites I will use full posts but prevent the archives from being indexed.
@ Darren - Glad you found it useful!
Monday, March 24th, 2008 at 8:53 pm
On some sites, I actually get some SE traffic to my category pages. I don’t want to de-index them because of that, so I stick with excerpts. They don’t take up too much space compared to just titles anyway.
Friday, March 28th, 2008 at 8:02 am
I use full post on home page and excerpt on category pages.
This is very easy. If your template doesn’t have this by default just go to archive.php and replace tags “the_content” for “the_excerpt”, and your done!
You can read more at the Wordpress Codex.