我觉得这是一只虫子。
创建新的自定义帖子类型时,似乎无法修改第一个子菜单项文本。我指的是允许您查看帖子列表的链接。
据我所知,它似乎只是复制了创建的主帖子类型菜单的名称。
是否有人知道如何修改此文本,以便主菜单元素显示“文章”,而帖子列表子菜单名称显示“管理文章”?
我的印象是"edit_item"
将控制要在te子菜单中显示的文本,但由于某些原因,这没有注册。
以下是我目前使用的代码:
//////////////////////////////////////////////////////////////////////////////
// CUSTOM POSTTYPE FOR -- ARTICLES
//////////////////////////////////////////////////////////////////////////////
add_action(\'init\', \'articles\');
function articles() {
register_post_type(\'articles\', array(
\'labels\' => array(
\'name\' => __(\'Articles\'),
\'singular_label\' => __(\'Article\'),
\'new_item\' => __(\'Add Article\'),
\'add_new\' => __(\'Add Article\'),
\'add_new_item\' => __(\'Add Article\'),
\'edit\' => __(\'Edit Article\'),
\'edit_item\' => __(\'Edit Article\'),
\'view\' => __(\'View Article\'),
\'view_item\' => __(\'View Article\'),
\'search_items\' => __(\'Search Articles\'),
\'not_found\' => __(\'No Articles Found\'),
\'not_found_in_trash\' => __(\'No Articles Found in Trash\'),
),
\'supports\' => array(
\'thumbnail\',
\'title\',
\'editor\',
\'author\',
\'revisions\',
),
\'rewrite\' => array(
\'slug\' => \'articles\',
\'with_front\' => false,
),
\'rewrite\' => true,
\'can_export\' => true,
\'show_ui\' => true,
\'menu_position\' => 3,
\'public\' => true,
\'query_var\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
));
}
add_filter(\'manage_edit-articles_columns\', \'add_new_articles_columns\');
function add_new_articles_columns($articles_columns) {
$new_columns[\'cb\'] = \'<input type="checkbox" />\';
$new_columns[\'article_thumbnail\'] = _x(\'Image\', \'column name\');
$new_columns[\'title\'] = _x(\'Article Title\', \'column name\');
$new_columns[\'article_excerpt\'] = _x(\'Article Excerpt\', \'column name\');
$new_columns[\'article_source\'] = _x(\'Article Source\', \'column name\');
$new_columns[\'author\'] = __(\'Created by\');
$new_columns[\'date\'] = _x(\'Last Action\', \'column name\');
return $new_columns;
}
add_action(\'manage_posts_custom_column\', \'manage_articles_columns\', 10, 2);
function manage_articles_columns($column_name, $id) {
global $wpdb;
switch ($column_name) {
case \'article_thumbnail\':
the_post_thumbnail( array(50,50) );
break;
case \'article_excerpt\': echo substr(get_the_excerpt(),0,500);
break;
case \'article_source\':
echo get_the_term_list($post->ID, \'content_sources\', \'\', \', \',\'\');
break;
default: break;
}
}