我需要在产品名称上方的woocommerce产品添加页面中显示我的自定义通知。
查看以下屏幕。下面标记的部分我需要显示自定义消息。
答案 0 :(得分:2)
尝试使用以下代码
function general_admin_notice() {
global $pagenow;
if ($pagenow == 'post-new.php' || $pagenow == 'edit.php' || $pagenow == 'post.php') {
if ('product' === get_post_type($_GET['post'])) {
echo '<div class="notice notice-warning is-dismissible">
<p>This notice appears on the settings page.</p>
</div>';
}
}
}
add_action('admin_notices', 'general_admin_notice');
答案 1 :(得分:0)
function filter_post_updated_messages( $message ) {
/***
echo '<pre>';
print_r($message['product']);
echo '</pre>';
***/
$publish_msg = $message['product'][6];
$publish_msg = str_replace('Product published.', 'Hi Great your new product published.', $publish_msg);
$message['product'][6] = $publish_msg;
return $message;
};
add_filter( 'post_updated_messages', 'filter_post_updated_messages', 30, 1 );