Advanced WordPress Admin Tip: Posts By Category

January 7th, 2010 by Stephen Cronin (Please wait) [Shortlink]

Go to Posts -> Edit in the WordPress Admin area and you’ll see a list of all the posts you have. There is a dropdown list called View all categories, which allows you to select a single category to view posts from. But…

What if you want to view posts from more than one category, or better yet, want to exclude posts from certain categories? Can’t do it right? Well not through the WordPress interface, but you can do it through URL parameters.

Finding Out Your Category Numbers

To make this work, you’ll need to know the category numbers for your categories. You can find these through either of the following two methods:

  1. Go to Posts -> Category screen and hold your mouse over the category in question. In your browser’s status bar you will see a URL which ends in ID=xx (xx is the number of the category).

OR

  1. While still in Posts -> Edit, select the category you want in the dropdown list and click Filter. You’ll be taken to a page showing only posts from that category. In the browser’s address bar you’ll see that the URL contains cat=xx (xx is the number of the category).

The first method is quicker if you want to look up multiple category numbers (you may want to write them down). The second method is better if you’re just after one or two category numbers – you’ll need to do this step anyway.

First Step

By default, the Posts -> Edit screen has a URL that ends in wp-admin/edit.php with no parameters, eg:

http://www.scratch99.com/wp-admin/edit.php

Rather than typing all the parameters, it makes sense to start with a URL that includes them.

If you haven’t already, select one of the categories you want to include / exclude in the dropdown list and click Filter. You’ll be taken to a page showing only posts from that category, but you will now have a URL that looks like this:

http://www.scratch99.com/wp-admin/edit.php?s&mode=list&action=-1&m=0&cat=92&action2=-1

We’re going to be changing the cat=xx part of the URL.

Note: Don’t bother trying to use the URLs in this post. My wp-admin section is password protected, so all you’ll get is the password prompt.

Displaying Posts From More Than One Category

Perhaps I want to display posts from more than one category – in my case, I may want to see all the posts from my WordPress and Web Development categories, but not from the rest of my categories (too much noise).

Easy. Simply edit the URL and change the cat=xx to cat=xx,xx (where xx is the category numbers that you want). In my case, I change the URL to the following (note the cat=4,65):

http://www.scratch99.com/wp-admin/edit.php?s&mode=list&action=-1&m=0&cat=4,65&action2=-1

Want posts from three categories? That’s right:

cat=xx,xx,xx

You’ve got it now!

Excluding Posts From Certain Categories

It’s also possible to exclude posts from certain categories from appearing in the Posts -> Edit screen.

Why would I want to exclude posts from certain categories? Actually, that’s how I started looking into this issue. I haven’t been posting much recently and, as a result, my weekly automatic lifestream digest posts pretty much filled up the screen:

too many noisy entries in Edit Posts list

I was having trouble seeing my real posts!

Thankfully it’s easy to exclude the category that these posts are in. Simply edit the URL and change the cat=xx to cat=-xx (where xx is the category number you want). In my case, I change the URL to the following (note the minus sign, eg: cat=-92):

http://www.scratch99.com/wp-admin/edit.php?s&mode=list&action=-1&m=0&cat=-92&action2=-1

The result:

A much better list with unnecessary posts removed

Want to exclude posts from more than one category? That’s right:

cat=-xx,-xx,-xx

Note: I follow the rule of having one category per post. I’m not quite sure what will happen if your posts have more than one category. Will they show up if you exclude one of the categories that they’re in? Probably, because they are also in a category you are including, but I don’t know for sure.

Final Thoughts

That’s all – it’s a fairly long post for a fairly simple tip. It’s probably not something that will be needed often, but in some circumstances it’s very useful to have greater control over which posts appear on the Edit Posts screen.

Like this article? Plus One it!

Tags: , ,

There are 9 reponses to this article. Visit the comments page.

Leave a Reply

Anti-Spam Quiz:


Stephen Cronin

is Manager of Online Service Delivery at a Queensland Government department & has been a freelance WordPress developer/consultant since 2007
*Content on this site is my own and is not related to my employer

Hire me - I'm expensive, but I'm very good!

WordPress Plugins

Want a Custom WordPress plugin? See my Services page.

Greasemonkey Scripts

Visit my home page at Userscripts.org.