add custom column in admin side

Posted: September 22, 2015 in Uncategorized

add_action( ‘admin_init’, ‘my_admin_init’ );
function my_admin_init() {
add_filter( ‘manage_edit-POSTTYPE_columns’, ‘my_new_POSTTYPE_column’);
add_action( ‘manage_POSTTYPE_posts_custom_column’, ‘POSTTYPE_column_info’, 10, 2);
}

function my_new_POSTTYPE_column( $column ) {
unset($column[‘comments’]);
unset($column[‘date’]);
unset($column[‘author’]);
$column[‘column1’] = ‘Column1 Name’;
$column[‘column2’] = ‘Column2 Name’;
$column[‘column3’] = ‘Column3 Name’;
$column[‘column4’] = ‘Column4 Name’;

return $column;
}

function POSTTYPE_column_info( $column_name, $post_id ) {
switch($column_name){
case ‘column1’:

echo “test”;
break;
case ‘column2’:
echo “test”;
break;
case ‘column3’:
echo “test”;
break;
case ‘column4’:
echo “test”;
break;
default:

break;
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s