Advertisement
thesufi

Adding custom column to default post table

Feb 7th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. //defining
  2. add_filter('manage_posts_columns', 'dct_table_head'); //use manage_{$post_type}_posts_columns for custom post type
  3. function dct_table_head( $defaults ) {
  4.     $defaults['column1']  = 'Column1';
  5.     $defaults['column2']    = 'Column2';
  6. }
  7.  
  8. //configuring data
  9. add_action( 'manage_posts_custom_column', 'dct_table_content', 10, 2 ); //use manage_{$post_type}_posts_custom_columns for custom post type
  10. function dct_table_content( $column, $post_id ) {
  11.     if ($column == 'column1') {
  12.     //do your stuff here
  13.     }
  14.     if ($column == 'column2') {
  15.     //do your stuff here
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement