WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to add a column to display the post_id from the wp_postmeta table. I would like to display it in the admin posts list. Here is my code:

add_filter( 'manage_edit-movie_reviews_columns', 'my_columns' ); 
function my_columns ( $columns ) {
  global $post;
  $columns['id'] = 'ID';  
  return $columns;
add_action( 'manage_posts_custom_column', 'populate_columns' );
function populate_columns( $column ) {
  if ($column == 'id'){
    echo $post_id;

The ID column is visible, but no post_id are in that column- it is just blank. Please can you suggest changes. I'm new to wordpress development so please be gentle.

share|improve this question
Well, you have curly quotes in the code. Other than that, what isn't working exactly? Please check the "Related" questions to the right --> – s_ha_dum Apr 10 '13 at 15:10
Thanks! I have corrected the curly quotes in ($column == ‘id’){ The post_id's aren't showing in the column, the column is just blank. There should be the post_ids here. – mattnewbie Apr 10 '13 at 15:15
where does $post_id come from? – Milo Apr 10 '13 at 15:29
@Milo Thanks for taking an interest! I now know that $post_id was wrong. I have changed the code for the correct code ( hope that is allowed on stackexchange). Please can you explain it? I'm new to wordpress development & confused by it. Thanks-again! – mattnewbie Apr 10 '13 at 15:33
@milo Thank-you again. Now resolved. – mattnewbie Apr 10 '13 at 15:38
up vote 1 down vote accepted

You haven't set $post_id so there is no reason is should display. If you have debugging enabled as you should when you are working, you would have spotted the error immediately.

What you need to do is:

add_action( 'manage_posts_custom_column', 'populate_columns' );
function populate_columns( $column ) {
  global $post;
  if ($column == 'id'){
    echo $post->ID;
share|improve this answer
Thank-you @s_ha_dum , I will use your code as it makes it much simpler than the code (now above) that I've found on the internet. Thanks-again! – mattnewbie Apr 10 '13 at 15:36
Thanks everyone. @S_ha_dum 's code provides the answer I was looking for. – mattnewbie Apr 10 '13 at 15:37
Please mark this as the "accepted" solution if it solved the problem. – s_ha_dum Apr 10 '13 at 15:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.