为了不从所有其他屏幕删除帮助,您需要始终返回上下文帮助文本,否则您的过滤器不会为非页面/帖子屏幕返回任何内容,因此不会显示任何内容。将返回键移到函数的底部,在if/else之外。此外,原始上下文帮助将连接到自定义消息的末尾,因此将其移到前面,将文本放在底部。因此:
function myprefix_page_help($contextual_help, $screen_id, $screen) {
if ($screen_id == \'page\') {
$contextual_help = $contextual_help.\'
<h5>Shortcodes</h5>
<p>Shortcodes help</p>\';
}
elseif ($screen_id == \'post\') {
$contextual_help = $contextual_help.\'
<h5>Post help</h5>
<p>Help is on its way!</p>\';
}
return $contextual_help;
}
add_filter(\'contextual_help\', \'myprefix_page_help\', 10, 3);