Back to the old WordPress 2.5, the post ID was displayed in WordPress admin. Afterwards, this feature was removed. I didn’t check why but now and then I feel it necessary to get the post ID easily.
An easy way is to visit the edit page of a post and check the URL. It looks something like:
10586 is the post ID.
It should have been much easier.
Follow this tutorial and the final result is to reveal the ID in the admin post lists.
The codes should go to your theme’s
functions.php, or a separate plugin which is what I recommended. Also to save your time, the whole pieces of codes in this tutorial is compressed to a simple plugin that you can download at the bottom.
Add custom columns
We’ll use a filter to add custom columns to admin post lists and an action to display the content.
It should work well with this little piece of code to reveal the post ID.
What if you want to reveal the page ID? How about category ID, tag ID, and even comment ID?
The solution is similar as above, you just have to find the right hooks. The common form is
Below is the full hooks for media, users, categories, custom post types and taxonomies.
So far you should see the ID for all the posts, comments, users and taxonomies. But it appear at the end and the width seams a little more exceeding what’s enough.
We have to make some additional tweaks.
Pulling the ID to the front
We just need to do some changes on the
Following codes will place the ID to the front, right after the checkbox.
And below is the codes to adjust the column width
Change the number as you like.
Here is the final whole codes.
Hope you find this useful. And here is the working plugin you can instant activate to use on your WordPress blogs.