Skip to Main Content

How to view custom notifications on WordPress

Divi: the easiest WordPress theme to use

Are you looking for the best WordPress themes and plugins?

Download the best plugins and WordPress themes on Envato and easily create your website. Already more than 49.720.000 downloads. [EXCLUSIVE]

Would you like to add notifications to your WordPress dashboard? Admin notifications are used by WordPress, themes and plugins, to display warnings and notices about certain information to users. In this tutorial, we'll show you how to add notifications on WordPress.

how view-of-notifications-on-wordpress

When and why use administrator notifications?

WordPress uses notifications to alert users to errors, warnings, and success messages.


Site owners, plugin authors, and theme developers can also use these notifications.

If you are working on a website for clients who are not familiar with WordPress, you can add notifications to display useful information about their dashboard.

Custom notifications can also be useful if you have a multi-author blog. You can add notifications to guide new writers and help them find their way.

However, we recommend that you use notifications carefully. They can be very boring and can ruin the user experience.

That said, let's throw in how you can add your own custom notifications on WordPress.

1 Method: Add Custom Notifications to WordPress Manually

This method requires you to add code to your WordPress site. If you've never done it before, then I invite you to read our tutorial on how to create a WordPress plugin.

Let's start.

You must first add this code to your theme's functions.php file or to your plugin.

function general_admin_notice () {global $ pagenow; if ($ pagenow == 'options-general.php') {echo ' This is a notification. '; }} add_action ('admin_notices', 'general_admin_notice');

This code displays a notification on the settings page with a yellow border and a button to close the notification. Here's how it will appear on your site:


If you study the code, you will notice that we used the $ pagenow variable to detect the current page.

Easily create your website with Elementor

Elementor allows you to easily create any website design with a professional look. Stop paying expensive for what you can do yourself. [Free]

After that, we added the condition that checks if the current page responds to the page where we want to display the notification.

If this is the case, then we will display the notification in a tag " div ". This div element uses a CSS class already defined in the WordPress style sheet.

You must use the class " notice »And you can choose« user-error "," Form-warning "," Form-success "Or" Form-info To customize the borders of the notification.

Optionally, you can use the class " is-dismissible Which adds a button to close the notification.

In addition to controlling the current page, you can add all kinds of conditions to display notifications during various scenarios.

For example, you want to display a notification only for users with the author role.

Here's what you can do:

function author_admin_notice () {global $ pagenow; if ($ pagenow == 'index.php') {$ user = wp_get_current_user (); if (in_array ('author', (array) $ user-> roles)) {echo ' Click Articles to start writing. '; }}} add_action ('admin_notices', 'author_admin_notice');

As you can see we have added some extra code to detect user role in our function.

Here's how it will appear on your site.


Feel free to make the changes you want.

2 Method: How to Add Notifications Manually

This method is simpler because it does not require adding code. However, it is only as flexible as the custom code method.

The first thing you need to do is to install and activate the plugin " KJM Admin Notices ". For more details, see our step by step guide on how to install a WordPress plugin.

Divi: The best WordPress theme of all time!

With over 701.000 downloads, Divi is the most popular WordPress theme in the world. It is complete, easy to use and comes with more than 62 free templates. [Recommended]

After activating the plugin, you must visit " Settings> KJM Admin Notices Page to configure the plugin settings.

kjm plugin-admin-notices

First of all, you need to check the option to enable notifications from KJM. The second option adds a custom post type where you can add and edit your custom notifications.

The plugin also allows you to send an email to registered users when posting a new review. You can check the box next to the option " Send the message If you want to use this feature.

You can also enable comments in your notifications which will allow users to respond to reviews by adding comments. To activate this function, check the box next to the option " Allow Comments ».

Do not forget to click on the button « Save Changes To save your settings.

You will then see a new item on the dashboard toolbar. This is the place where you can add and edit your personalized notifications.

We will create your first personalized notification.

Go to " Notices> Add Notice ". You will see a screen similar to the WordPress post edit screen.


Start by adding a title to your notification, then add the content of the notification. You can select the category of notifications on the right.

Then you must select the roles of the users who will see this notification.


You can optionally show or hide the title, author and date, and the button close a notification. Once you are done, click on the publish button and your notification will now be available.


Easily create your Online Store

Download free WooCommerce, the best e-commerce plugins to sell your physical and digital products on WordPress. [Recommended]

« KJM Admin Notices Allows you to manage your notifications without writing code. You can delete or draft a notification that you no longer want to view.

Using the email feature, you can also alert users by email, even if they don't log into your dashboard.

You can also take a look at the plugin « WP Notification Center Which adds a Facebook-like notification center to your blog. Users can click the notification icon to view their notifications.


That's it for this tutorial. I hope you will be able to add notifications to your WordPress blog.

This article features 0 comments

Leave a comment

Your email address will not be published. Required fields are marked with *

This site uses Akismet to reduce unwanted. Learn more about how your comments data is used.

Back To Top