I love Wordpress, it’s made web publishing and blogging incredibly easy and available for so many people.
But, Depending on your theme or setup, it’s also easy to make hundreds of pages of duplicate content within your own domain. For instance under the categories pages, by default your content is duplicated and paginated based on your posts_per_page setting. So some of your older posts can be incredibly difficult for users and search engines to get to.
My goal was to fix this using these two changes:
Read on for how I did it…
WordPress uses the first Template file it finds in your current Theme’s directory from the following list (assuming this is for category 6).
So, the easiest way to change the amount of posts per page shown for categories, is to do the following:
< ?php get_header(); ?>< ?php get_header(); query_posts( 'posts_per_page=-1&cat=' . $cat ) ?>This was also a simple quick change - I again edited my category.php file and looked for the following line:
< ?php if (have_posts()) : ?>
Deleted everything between that if statement and its endif and put in the following:
<h1 id="cat_h1">< ?php single_cat_title() ?></h1>
<ul>
< ?php while (have_posts()) : the_post(); ?>
<div class="post">
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="< ?php _e('Permanent link to'); ?> < ?php the_title(); ?>">< ?php the_title(); ?></a></li>
</div>
< ?php endwhile; ?>
</ul>
With these two easy changes, I now show all posts within my categories regardless of my options settings, and have removed the duplicate content from the category pages by making every category article a link.
If you aren’t already using it, I also recommend the Permalink Redirect Wordpress Plugin to help keep your URL schema straight and to ensure that there is only one URL associated with each blog entry.
Let me know how this works out for you, hopefully you find these changes useful.
May 2nd, 2007 at 2:34 am
Thanks for the tip.. I am using Andreas09 and have my categories set up as subcategories within parent categories, and wanted to show all post links for the parent and all children. Or just the individual children as desired.
Was really scratching my head with the max 10 items p/page when by chance ran across your tip.
It works great and lists as many posts as there are for whatever category or subcategory is chosen..
Thanks again.
March 18th, 2008 at 3:07 am
Thank you. I searched for hours until I found your code. It is much appreciated.
April 15th, 2008 at 10:32 am
Thanks! Was looking for a while for how to control posts_per_page on archive pages… This worked a treat.