Custom Message in WP Admin Area

A quick little tutorial.

Recently, I had to leave a warning message on the Reading area of the Settings section on a clients website. Why? Well, the theme was dependent on working as expected as long as a static page was set. Of course, that probably means there’s some reworking to be done on the theme, but it was considerable reworking the client didn’t have a budget for, so we decided the best option is to place a warning message on that page saying, “Don’t Touch!”.

I tried a few scenarios to find the perfect fit for what I needed. Let’s post a little message on the Reading page in the admin area above everything else.

Open your themes functions.php

Paste in this function

I’ll admit, this is not the most professional scenario and I’ll probably get some hate mail, but if there is some special reason you need to post a special message on any page within the admin area, this exact code will do the trick. Let’s discuss the code.

We bring in the global variable $pagename which stores the name of the page currently being viewed in the admin area.

We check to make sure we are currently viewing the Reading page and then we display a message using some default WordPress styles like Error, which will give us a big read box above the settings fields. I also set this to use an h3 which is fairly large and bold. Just enough to stick out… obnoxiously..

Anyways, upload your file and you’ll see your error message!