admin管理员组文章数量:1026989
I need to show my client error message on all admin pages.
I have the following code, that adds a custom notice only on the admin dashboard page:
add_action('admin_bar_menu', 'custom_toolbar_link2', 999);
function general_admin_notice(){
global $pagenow;
if ( $pagenow == 'index.php' ) {
echo '<div class="notice notice-error">
<h3>My custom text</h3>
</div>';
}
}
Is there any way to display this notice on all admin pages?
I need to show my client error message on all admin pages.
I have the following code, that adds a custom notice only on the admin dashboard page:
add_action('admin_bar_menu', 'custom_toolbar_link2', 999);
function general_admin_notice(){
global $pagenow;
if ( $pagenow == 'index.php' ) {
echo '<div class="notice notice-error">
<h3>My custom text</h3>
</div>';
}
}
Is there any way to display this notice on all admin pages?
Share Improve this question edited Mar 22, 2019 at 14:32 cjbj 15k16 gold badges42 silver badges89 bronze badges asked Mar 22, 2019 at 14:17 JurajJuraj 1542 silver badges11 bronze badges2 Answers
Reset to default 1function my_admin_notice() {
/*
* The class of admin notice should be "notice" plus any one of
* -"notice-error",
* -"notice-warning",
* -"notice-success"
* -"notice-info".
* Optionally use "is-dismissible" to apply a closing icon.
*/
echo '<div class="notice notice-info"><p>Custom notice text</p></div>';
}
add_action( 'admin_notices', 'my_admin_notice' );
The only thing is, these notices does not show up on New Post, Edit Post and similar where Gutenberg reins. There must be the solution, but I can't find it right now.
Sure there is a method to do this. You just need to attach your function to a different hook, admin_notices
. You can even add classes that will turn into coloured bars, telling the user how important the message is.
I need to show my client error message on all admin pages.
I have the following code, that adds a custom notice only on the admin dashboard page:
add_action('admin_bar_menu', 'custom_toolbar_link2', 999);
function general_admin_notice(){
global $pagenow;
if ( $pagenow == 'index.php' ) {
echo '<div class="notice notice-error">
<h3>My custom text</h3>
</div>';
}
}
Is there any way to display this notice on all admin pages?
I need to show my client error message on all admin pages.
I have the following code, that adds a custom notice only on the admin dashboard page:
add_action('admin_bar_menu', 'custom_toolbar_link2', 999);
function general_admin_notice(){
global $pagenow;
if ( $pagenow == 'index.php' ) {
echo '<div class="notice notice-error">
<h3>My custom text</h3>
</div>';
}
}
Is there any way to display this notice on all admin pages?
Share Improve this question edited Mar 22, 2019 at 14:32 cjbj 15k16 gold badges42 silver badges89 bronze badges asked Mar 22, 2019 at 14:17 JurajJuraj 1542 silver badges11 bronze badges2 Answers
Reset to default 1function my_admin_notice() {
/*
* The class of admin notice should be "notice" plus any one of
* -"notice-error",
* -"notice-warning",
* -"notice-success"
* -"notice-info".
* Optionally use "is-dismissible" to apply a closing icon.
*/
echo '<div class="notice notice-info"><p>Custom notice text</p></div>';
}
add_action( 'admin_notices', 'my_admin_notice' );
The only thing is, these notices does not show up on New Post, Edit Post and similar where Gutenberg reins. There must be the solution, but I can't find it right now.
Sure there is a method to do this. You just need to attach your function to a different hook, admin_notices
. You can even add classes that will turn into coloured bars, telling the user how important the message is.
本文标签: hooksDisplay pagenow error notice on all admin pages
版权声明:本文标题:hooks - Display $pagenow error notice on all admin pages 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745665450a2162150.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论