使用这篇写得很好的后期教程Edit dashboard\'s help tab 我完全控制所有标准WordPress管理屏幕。
是否可以修改此选项以将“帮助”选项卡添加到自定义帖子类型?
使用这篇写得很好的后期教程Edit dashboard\'s help tab 我完全控制所有标准WordPress管理屏幕。
是否可以修改此选项以将“帮助”选项卡添加到自定义帖子类型?
使用此代码解决您的问题。
function custom_help() {
global $post_ID;
$screen = get_current_screen();
if( isset($_GET[\'post_type\']) ) $post_type = $_GET[\'post_type\'];
else $post_type = get_post_type( $post_ID );
if( $post_type == \'listing\' ) :
$screen->add_help_tab( array(
\'id\' => \'you_custom_id\', // unique id for the tab
\'title\' => \'Custom Help\', // unique visible title for the tab
\'content\' => \'<h3>Help Title</h3><p>Help content</p>\', //actual help text
));
$screen->add_help_tab( array(
\'id\' => \'you_custom_id_2\', // unique id for the second tab
\'title\' => \'Custom Help 2\', // unique visible title for the second tab
\'content\' => \'<h3>Help Title 2</h3><p>Help content</p>\', //actual help text
));
endif;
}
add_action(\'admin_head\', \'custom_help\');
此处介绍的添加帮助选项卡的方法Edit dashboard\'s help tab 只要编辑CustomPostType功能(列表管理屏幕)出现在CustomPostType功能(编辑/添加新管理屏幕)之前,也适用于自定义帖子类型。对于自定义post类型分类法,请使用edit taxonomyName。干杯
昨天在本教程中,我碰巧遇到了这个答案:
上下文帮助功能是一个降序选项卡,可以在可用页面的右上角看到。让我们看看如何更改内容。
function my_contextual_help( $contextual_help, $screen_id, $screen ) {
if ( \'product\' == $screen->id ) {
$contextual_help = \'<h2>Products</h2>
<p>Products show the details of the items that we sell on the website. You can see a list of them on this page in reverse chronological order - the latest one we added is first.</p>
<p>You can view/edit the details of each product by clicking on its name, or you can perform bulk actions using the dropdown menu and selecting multiple items.</p>\';
} elseif ( \'edit-product\' == $screen->id ) {
$contextual_help = \'<h2>Editing products</h2>
<p>This page allows you to view/modify product details. Please make sure to fill out the available boxes with the appropriate details (product image, price, brand) and <strong>not</strong> add these details to the product description.</p>\';
}
return $contextual_help;
}
add_action( \'contextual_help\', \'my_contextual_help\', 10, 3 );
上述代码将根据screen->id
, 当您只想在特定的管理页面或CPT中显示帮助选项卡时,这一点很重要,只需针对CPT中的slug。