Retrieve Category ID in WordPress using PHP instead of cheat sheet of hovering the mouse within the Administrative control Panel. It is really easy. In previous article, we have shown how to serve Category Specific Ad Unit Delivery in WordPress using Conditional Tags. But, obviously this is not what we always want by doing a simple Google web search with the term Retrieve Category ID in WordPress. Hovering the Mouse or finding from Browser address bar to retrieve Category ID in WordPress is too primitive and possibly difficult to remember while working with lot of posts and categories. However, there is a deprecated function to retrieve Category ID in WordPress and searching on Google find outs either of these three ways. Definitely, we are not going to describe them.
Retrieve Category ID in WordPress using Plugin
There should not be any shame if you are new to WordPress or has no chance or love to learn PHP or WordPress Function. It is safer for them to use some good WordPress Plugin to retrieve category ID in WordPress. Here is one such :
As we are describing advanced, experimental function, newbies should not test them on their working WordPress blog.
Retrieve Category ID in WordPress using PHP
This is what our motto of the original article was. This no more works :
Obviously, the answers on WordPress forums based on this reference also do not work but unfortunately Google Search do not understand this thing, as search engine is not a human. But, this one works :
Obviously, you can modify it a bit to use for your own purpose :
The code returns the ID of a WordPress category from its name, without knowing in advance. Very useful for tag pages, category and index. Source file
get_cat_ID() is located in wp-includes/category.php. This is a documented WordPress function.
Follow the Author of this article :