管理列
使用
manage_{post-type-name}_columns
过滤器:仅根据切换
$capability
在
$post_columns
大堆
function wpse19435_manage_columns( $posts_columns )
{
// First role: add a column - take a look at the second function
if ( current_user_can( $capability_admin ) )
{
$posts_columns[\'some_column_name\'] = _x( \'Whatever\', \'column name\' );
}
// second role: remove a column
elseif ( current_user_can( $capability_other_role ) )
{
unset( $posts_columns[\'comments\'] );
}
// default
else
{
// do stuff for all other roles
}
return $posts_columns;
}
add_filter( \'manage_{post-type-name}_columns\', \'wpse19435_manage_columns\' );
Add a column
function wpse19435_manage_single_column( $column_name, $id )
{
switch( $column_name )
{
case \'some_column_name\' :
// do stuff
break;
default :
// do stuff
break;
}
}
add_action(\'manage_{post-type-name}_custom_column\', \'wpse19435_manage_single_column\', 10, 2);