Post ID Column

Add a Column to Easily Note the Post ID

| 5 Comments

After recently writing my post “Include a Post within a Page or Post“, I was in the process of writing a tutorial to give you an easier way to find the Post ID, by adding a column in the post editor screen.

Well, it seems that WP Snipp pipped me to the post as they just published a post doing exactly that. So rather than go through the rigmarole of writing the snippet myself, I’m going to give you his snippet. Drop it into your functionality plugin to use it:

// ADD COLUMN IN EDITOR FOR POST ID //

function posts_columns_id($defaults){
    $defaults['wps_post_id'] = __('ID');
    return $defaults;
}
function posts_custom_id_columns($column_name, $id){
	if($column_name === 'wps_post_id'){
        	echo $id;
    }
}

add_filter('manage_posts_columns', 'posts_columns_id', 5);
    add_action('manage_posts_custom_column', 'posts_custom_id_columns', 5, 2);
    add_filter('manage_pages_columns', 'posts_columns_id', 5);
    add_action('manage_pages_custom_column', 'posts_custom_id_columns', 5, 2);

Now when you go to your posts (or pages) screen, you’ll see that there’s an additional column that shows your post ID for easy reference. Pretty handy huh? Thanks for the snippet Kevin.

Categories: Code & Snippets | Permalink

What next?

Hire me

If you couldn't quite manage this yourself, find it too intimidating, or just don't have the time to do it, you can always hire Dave to do it. Please get in touch so that we can discuss your needs.

Leave a comment

If you have a question, update, or comment about the tutorial, please leave a comment. I try and respond to every comment, though it may take a few days, so please check back soon.

Keep your site backed up, updated & secure

I provide a service called The WP Butler, which helps you stay on top of the maintenance of your WordPress site. Instead of worrying about whether your site is secure, updated and backed up, The WP Butler handles all that for you on a regular basis, so that you can focus on doing what you do best. If you use coupon DIWW, you'll save 15% on our already-low-prices for all maintenance plans.

Author: Dave Clements

Dave Clements has been building websites for close to a decade and in 2010, he formalised that by starting his own company, The UK Edge. He now works on a variety of web projects, from simple tasks like installing a new WordPress site, to consulting on problems, or redesigning his clients' sites. He also runs Do It With WordPress, a site dedicated to providing free tutorials on WordPress. When he's not building your new website, you can find Dave eating Wheat Thins, spending time with friends and family, watching Indie films, fostering kittens from the local Humane Society, listening to some dubstep, dance and electronic rock, and exploring the world.

5 Comments

  1. This is very useful. Considering blogs that have thousands of articles, knowing the post id can help a lot.

    But small blogs don’t need it, I think… or not? anyway, great post

  2. Hey glad to see that you like the snippet and yes this was something that I have found immensely useful.

  3. This is pretty cool, Dave. I just go to the permalink at the top of a post a click edit. The serial number shows up. I don’t really edit it!

    • Yeah, I was thinking of writing a quick tutorial that shows information about the post to just the admin on the post itself, including the Post ID for instance. Much simpler than hunting for it in a URL.

Leave a Reply