您可以使用添加列the manage_posts_column
filter, 其中添加两个新的数组元素,使用自定义键名和头名称作为值。
add_filter(\'manage_posts_columns\', \'wpse_3531_add_seo_columns\', 10, 2);
function wpse_3531_add_seo_columns($posts_columns, $post_type)
{
$posts_columns[\'seo_score\'] = \'SEO score\';
$posts_columns[\'seo_keyword\'] = \'SEO keyword\';
return $posts_columns;
}
显示每行的函数,
_post_row()
, 然后启动
manage_posts_custom_column
它不知道的每个列的操作。您可以挂接此函数以显示自己的数据。
add_action(\'manage_posts_custom_column\', \'wpse_3531_display_seo_columns\', 10, 2);
function wpse_3531_display_seo_columns($column_name, $post_id)
{
if (\'seo_score\' == $column_name) {
echo \'SEO score for post with ID \' . $post_id;
}
if (\'seo_keyword\' == $column_name) {
echo \'SEO keyword for post with ID \' . $post_id;
}
}