Haven't found an info about it anywhere. So I thought I will ask here.

Basically I'm looking for a simple AJAX code, that will check the database and send a signal when a new post has been made or added to the database.

In a real time, without reloading the page.

By signal, I mean something like this:

If the new post was added to the database

--do something--


--do something else--

What I want to do is to notify my Wordpress users on the front end with a small colored dot near the "Home" button to go and check it out.

Just like Twitter has:

enter image description here

Any help would be appreciated.

1 Answer 1


I would, on admin init hook check latest post's ID against a saved latest post's ID in options table and if not that latest one, add a class has-new to the dashboard entry (#adminmenu .menu-icon-dashboard), so you can create a dot on that element with ::after.

Then when user clicks the posts page (check with get_current_screen()) save that latest ID in the options table, so next check would thus not add the has-new class.

Remember to check only for post types that you want to be notified about, and you might want to exclude non published posts in that check.


My answer is not an ajax solution as you asked, so this will not suddenly update the admin panel when it's idle. For that to work, one would have to simply do that check on interval, so the check would be an ajax function and the interval in some admin.js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.