How to find page, post, category and tag IDs in WordPress
- 1 Comment
Although not very often, there’ll be times when you’ll want to know a specific ID of a WordPress page, post, category or tag – such as when you’re trying to write a piece of conditional code or a particular plugin (or even theme) you’re using requires you to enter it. Unfortunately, although it once did, WordPress no longer displays this piece of sometimes important information in the dashboard – meaning countless newbie-WordPress-users are left hunting high and low for it if/when the need to know it finally arises (most of whom will likely as not end up turning to Google and typing something like ‘Where can you find page IDs in WordPress’).
Luckily, there is, in fact, an extremely straight-forward way to access this particular piece of sneaky-WordPress information with ease – without having to install ANY extra plugins*!
Here’s how (note: we’ll go through the process for page IDs, but you can use exactly the same process to find IDs for categories, tags, posts and even media files):
Navigate to ‘Pages’ -> ‘All Pages’, and then click on the specific page for which you’d like to find the ID of. In this example we’ll choose ‘Sample Page’ (since it’s the only page in the menu in our install).
Once you’re in the edit page, take a look at the web address (URL) in your browser’s navigation bar and you should see something like “http://yourdomainname.com/wp-admin/post.php?post=2&action=edit” (or alternatively, if you’re using a browser like Firefox, which will show the web address of a page simply by hovering over a link, you’ll be able to skip this particular step altogether and view the same web address by simply hovering over one of the page titles – such as, in our case: ‘Sample Page’ – mentioned in step 1).
Take a good look at the web address found in step 3. See the bit that reads “post=2“**? …the “2” is the ID! I.e. the ID of this particular page is 2.
*start installing plugins for simple tasks like this and before you know it you’ve got more plugins than you know what to do with and a WordPress install that’s both a pain to manage (more plugins = more updates, etc) and as slow as a snail stuck in super glue!
**note: for categories and tags, the ID will come immediately after “tag_ID=” (rather than “post=”).
…the only hard part is remembering how to do it when you need to!