{"id":41728,"date":"2025-10-30T23:19:47","date_gmt":"2025-10-30T21:19:47","guid":{"rendered":"https:\/\/coma.lv\/2025\/10\/30\/how-to-add-your-own-admin-notices-in-wordpress\/"},"modified":"2025-10-30T23:19:47","modified_gmt":"2025-10-30T21:19:47","slug":"how-to-add-your-own-admin-notices-in-wordpress","status":"publish","type":"post","link":"https:\/\/coma.lv\/en\/2025\/10\/30\/how-to-add-your-own-admin-notices-in-wordpress\/","title":{"rendered":"How to Add Your Own Admin Notices in WordPress"},"content":{"rendered":"\n<p style=\"text-align: left;\">Admin notices are used by themes, plugins and the WordPress core to display warnings, tips and other important information on the user&#8217;s screen. In this article we will look at how you can add your own notices in WordPress and manage them for your own needs.<\/p>\n<h2 style=\"text-align: left;\">Why and When Should You Use Notices?<\/h2>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36822 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-020536.jpg\" alt=\"WordPress\" width=\"1422\" height=\"433\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-020536.jpg 1422w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-020536-300x91.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-020536-1030x314.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-020536-768x234.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-020536-705x215.jpg 705w\" sizes=\"auto, (max-width: 1422px) 100vw, 1422px\" \/><\/p>\n<p style=\"text-align: left;\">If you work on a site for clients who are not very familiar with WordPress, you can add admin notices to display useful information throughout the admin area. This is especially useful if you are building a site for a team of authors: notices help newcomers get up to speed faster. However, we advise approaching this with caution, as they can be very annoying. Now let&#8217;s see how you can enable them.<\/p>\n<h2 style=\"text-align: left;\">Method 1. Add Your Own Notices Manually<\/h2>\n<p style=\"text-align: left;\">This method requires you to add code to your WordPress site. You need to paste the following snippet into your theme&#8217;s functions.php file or into a custom plugin:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nfunction general_admin_notice() {\r\n    global $pagenow;\r\n\r\n    if ( $pagenow === &amp;#039;options-general.php&amp;#039; ) {\r\n        echo &amp;#039;\r\n        &amp;lt;div class=&amp;quot;notice notice-warning is-dismissible&amp;quot;&amp;gt;\r\n            &amp;lt;p&amp;gt;This notice appears on the settings page.&amp;lt;\/p&amp;gt;\r\n        &amp;lt;\/div&amp;gt;\r\n        &amp;#039;;\r\n    }\r\n}\r\nadd_action(&amp;#039;admin_notices&amp;#039;, &amp;#039;general_admin_notice&amp;#039;);\r\n<\/pre>\n<p style=\"text-align: left;\">This code displays a notice on the settings page. This is how your notices will look in the admin area:<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36823 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-021414.jpg\" alt=\"WordPress\" width=\"1059\" height=\"321\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-021414.jpg 1059w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-021414-300x91.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-021414-1030x312.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-021414-768x233.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-021414-705x214.jpg 705w\" sizes=\"auto, (max-width: 1059px) 100vw, 1059px\" \/><\/p>\n<p style=\"text-align: left;\">If you study the code, you will notice that we have the <code data-start=\"1971\" data-end=\"1981\">$pagenow<\/code> variable, which detects the current page. After that we added a condition that checks whether the page is suitable for showing the notice. If it is, we show the notice wrapped in a <code data-start=\"2129\" data-end=\"2136\">&lt;div&gt;<\/code> element with WordPress admin interface classes. The available classes are: <code data-start=\"2198\" data-end=\"2212\">notice-error<\/code>, <code data-start=\"2215\" data-end=\"2231\">notice-warning<\/code>, <code data-start=\"2234\" data-end=\"2250\">notice-success<\/code>, <code data-start=\"2253\" data-end=\"2266\">notice-info<\/code>. And the <code data-start=\"2276\" data-end=\"2292\">is-dismissible<\/code> class adds a button for closing the notice.<\/p>\n<div style=\"text-align: left;\">\n<p>Besides checking the page, you can add all kinds of conditions for showing notices. For example, show a notice only to users with the <strong data-start=\"2452\" data-end=\"2462\">Author<\/strong> role:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nfunction author_admin_notice() {\r\n    global $pagenow;\r\n\r\n    if ( $pagenow === &amp;#039;index.php&amp;#039; ) {\r\n        $user = wp_get_current_user();\r\n\r\n        if ( in_array( &amp;#039;author&amp;#039;, (array) $user-&amp;gt;roles, true ) ) {\r\n            echo &amp;#039;\r\n            &amp;lt;div class=&amp;quot;notice notice-info is-dismissible&amp;quot;&amp;gt;\r\n                &amp;lt;p&amp;gt;Click on &amp;lt;a href=&amp;quot;edit.php&amp;quot;&amp;gt;Posts&amp;lt;\/a&amp;gt; to start writing.&amp;lt;\/p&amp;gt;\r\n            &amp;lt;\/div&amp;gt;\r\n            &amp;#039;;\r\n        }\r\n    }\r\n}\r\nadd_action(&amp;#039;admin_notices&amp;#039;, &amp;#039;author_admin_notice&amp;#039;);\r\n<\/pre>\n<p data-start=\"2938\" data-end=\"3051\">In this case an additional check of the user&#8217;s role has been added. Such a notice will appear only for authors.<\/p>\n<p>Feel free to experiment with different filters and conditions.<\/p>\n<h2>Method 2. Add Notices with a Plugin<\/h2>\n<p>This method is simpler because it does not require you to use code. The <a href=\"https:\/\/wordpress.org\/plugins\/wp-custom-admin-interface\/\" target=\"_blank\" rel=\"noopener\">WP Custom Admin Interface<\/a> plugin handles this task well. However, the free version of this plugin has limitations: you can create only one notice. If you want to create several notices, consider <strong data-start=\"1678\" data-end=\"1708\">Custom Admin Interface Pro<\/strong>, which removes these limitations and unlocks the full functionality.<\/p>\n<p>After installing and activating the plugin, a new menu <strong data-start=\"397\" data-end=\"439\">Custom Admin Interface \u2192 Admin Notices<\/strong> will appear in the admin area, where you can create and configure notices for any users and sections. You will see something like a post editor.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36825 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-024934.jpg\" alt=\"WordPress\" width=\"1877\" height=\"846\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-024934.jpg 1877w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-024934-300x135.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-024934-1030x464.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-024934-768x346.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-024934-1536x692.jpg 1536w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-024934-1500x676.jpg 1500w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/11\/Ekranuznemums-2025-11-14-024934-705x318.jpg 705w\" sizes=\"auto, (max-width: 1877px) 100vw, 1877px\" \/><\/p>\n<p data-start=\"687\" data-end=\"1065\">In the <strong data-start=\"694\" data-end=\"712\">Notice Content<\/strong> field you enter the text of the notice. Here you can use special tags such as <code data-start=\"794\" data-end=\"810\">[CURRENT_YEAR]<\/code>, <code data-start=\"812\" data-end=\"829\">[WEBSITE_TITLE]<\/code>, <code data-start=\"831\" data-end=\"850\">[WEBSITE_TAGLINE]<\/code>, <code data-start=\"852\" data-end=\"867\">[WEBSITE_URL]<\/code>, <code data-start=\"869\" data-end=\"892\">[ADMIN_EMAIL_ADDRESS]<\/code>, as well as user-related tags: <code data-start=\"935\" data-end=\"954\">[USER_FIRST_NAME]<\/code>, <code data-start=\"956\" data-end=\"974\">[USER_LAST_NAME]<\/code>, <code data-start=\"976\" data-end=\"993\">[USER_NICKNAME]<\/code> and <code data-start=\"996\" data-end=\"1010\">[USER_EMAIL]<\/code>. You can add media, visual elements or code.<\/p>\n<p data-start=\"1067\" data-end=\"1564\">Next you can choose the notice color via <strong data-start=\"1110\" data-end=\"1132\">Admin Notice Color<\/strong> and set the expiry date via <strong data-start=\"1175\" data-end=\"1200\">Admin Notice End Date<\/strong> in the <code data-start=\"1211\" data-end=\"1223\">YYYY-MM-DD<\/code> format. If you wish, you can make the notice <strong data-start=\"1263\" data-end=\"1278\">dismissable<\/strong> so that users can close it. There is also an option for exceptions: the notice is shown to all users except those you add in the <strong data-start=\"1437\" data-end=\"1462\">Add an exception case<\/strong> section. After making all the settings, click <strong data-start=\"1506\" data-end=\"1527\">Save All Settings<\/strong> to activate the notice.<\/p>\n<p>Besides letting you add your own notices, WP Custom Admin Interface offers a wide range of features, such as personalizing the menu, adding your own widgets, simplifying the interface for authors or clients and managing access to admin sections.<\/p>\n<hr \/>\n<p><em>Our specialization is WordPress website development and maintenance. Contact us for a free consultation \u2014 <a href=\"mailto:vadim@coma.lv\">vadim@coma.lv<\/a>, <a href=\"tel:+37129394520\">+371 29394520<\/a><\/em><\/p>\n<hr \/>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Admin notices are used by themes, plugins and the WordPress core to display warnings, tips and other important information on the user&#8217;s screen. In this article we will look at how you can add your own notices in WordPress and manage them for your own needs. Why and When Should You Use Notices? If you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":37172,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1225,1407],"tags":[],"class_list":["post-41728","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","category-tutorials"],"_links":{"self":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/comments?post=41728"}],"version-history":[{"count":0,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41728\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media\/37172"}],"wp:attachment":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media?parent=41728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/categories?post=41728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/tags?post=41728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}