WordPress Basics: Category ID’s
Understanding Category ID’s is absolutely fundamental if you are doing any custom WordPress theme work. The thing is, obvious pieces of advice tend to get overlooked in tutorial sites. So, here’s a basic overview on how you can locate a Category ID.
Any WordPress code snippet that calls or sorts content based on categories will use a unique Category ID. Unlike almost everything else in WordPress, the system actually generates these codes and there is no obvious place to locate them. To find the Category ID for your site go to to the main Categories page and hover over your list of categories. Here I have hovered over the category “The Work” in our site:
With your mouse over the category name, you should see a URL string at the bottom of your browser in the status area. At the end of that string you will see text that says “tag_ID=” and then a number, like this:
You can see that when I hover over “The Work” the URL displays that it’s Category ID is 11. The number at the end of the string is the category ID that WordPress has given your specific category.
To call the posts using the Category ID you would simply use that number. The snippet below, from the Bridge site, shows how we display our work by calling Category 11.
So, that is the basics on Category ID’s. Sometimes it’s the simple things that drive you crazy and I hope this helps you make progress.