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.
October 21st, 2008 at 10:28 am
thank you, I’ve been searching for hours too for this matter, when I’m putting the code (at the wordpress outside the loop), it access all the category. But when I tried yours, It shows the post under the category that clicked.
Regards,
nasgorkam
November 7th, 2008 at 4:40 am
Thank you heaps for this post it was essential for me in customizing my website!
December 17th, 2008 at 12:52 pm
It’s been quite some time since you’ve posted this, but I have to say thank you. Helped me a lot.
Cheers!
January 5th, 2009 at 5:57 pm
Was looking for a long time for this and it really works really fine to me!
Maybe it could be standard in the next release?
Thanks again!
Regards,
Jasper
April 23rd, 2009 at 2:01 am
Looking for this for days, and even trying plugins and everything. You made it simpler. Thank you!
June 24th, 2009 at 8:33 pm
This saved my hide! I needed to have the universal page limit set to 1 for a particular site I’m building, but I wanted the archive to show all the story titles, not just one so I had to find a way to manipulate the code. This worked like a charm, but particularly the part where you inadvertently outlined how to reference the currently “selected” tag and category: &cat=’ . $cat. That was the only thing I couldn’t figure out. Thanks so much!
July 26th, 2010 at 9:46 am
Thanks for this. I have been trawling the net for about 90 minutes looking for a solution to my category pages (show ALL posts in a category, and display LINKS only), and this is PRECISELY what I was looking for. Surprised you don’t have more comments, as I think this is an invaluable tool for using WordPress as a CMS.