January 17, 2017

Wordpress admin - How add custom column in post listing table?


- If you want to add custom column in wordpress admin all post listting, then you just need to add some function on functions.php file.

- Here I try to explain with one example like if you want to add Post ID on admin post listing page.



- Example:

File: wp-content/yourtheme/functions.php

//BELOW FUNCTION FOR DISPLAY HEADER TITLE
add_filter('manage_posts_columns', 'columns_header');

function columns_header('$default') {
 $default['post_id'] = 'Post ID';
 return $default;
}


//BELOW FUNCTION FOR DISPLAY VALUE ON THAT COLUMN

add_action('manage_posts_custom_column', 'columns_content', 10, 2);

function columns_content($column_name, $post_id) {
 if($column_name == 'post_id') {
  echo $post_id;
 }
}

Enjoy!

5 comments:

  1. There are lots of information about latest technologies and how to get trained in them, like this have spread around the web, but this is an individual one according to me. The strategy you have updated here will make me to get trained in future technologies.Thank you for sharing such a great article with us.
    Engineering Colleges, ECE Engineering Colleges in Chennai

    ReplyDelete
  2. I’ve been surfing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my opinion, if all webmasters and bloggers made good content as you did, the web will be a lot more useful than ever before.
    how to make a wordpress website

    ReplyDelete

The Future of Technology: Emerging Trends to Watch in 2025

Introduction As we navigate through 2025, the technological landscape continues to evolve at an unprecedented pace. Innovations that once se...