Leave a notice for your authors directly in post editor

While you can easily put a notice on top of your website for every visitor who loads one of your pages, there are situations when you will want to add some extra notifications for your authors on the backend.

For example, if you make some changes to the way post editor works, it would be a good idea to notify your authors about it. While you can do that in person or send a simple e-mail message explaining the changes done to post editors, you will probably want to add a little reminder on the right place.

We have already shown you how to limit the number of words per post, do the same for post titles or even allow/deny authors from posting to specific categories.

Yes, all those customizations will show your authors error messages if they don’t work with the news rules, but it might be a good idea to show them a little reminder about new limitations.

In this article, we are about to show you how to add a simple message just below the post title or below the content box.

Add a notice below the title:

  1. Open functions.php
  2. Copy and paste this code:
  3. function below_the_title() {
    echo '<h2>Make sure that your title isn’t longer than 100 characters</h2>';
    }
    add_action( 'edit_form_after_title', 'below_the_title' );
    
  4. Change the message on the 2nd line
  5. Save changes

Add a notice below the content box:

  1. Open functions.php
  2. Copy and paste this function:
  3. function below_the_editor() {
    echo '<h4>Your article need at least 400 words before you can publish it</h4>';
    }
    add_action( 'edit_form_after_editor', 'below_the_editor' );
    
  4. Change the message on the 2nd line
  5. Save changes

As you can see from the code, text you’re adding comes in the simplest form. Since you’re adding the text with a PHP echo statement, it means that you can output any HTML code with your text. In this case, that means that you are free to add any HTML code to change text characteristics.

For example, let’s change the text color for the second function:

echo '<h3><font color="red">Make sure your title is punchy and relevant to the content.</font></h3>';

 

Let’s add a link to your notification:

echo ' <a href="http://www.firstsiteguide.com"> Learn more about WordPress right here </a>';

 

If you’re wondering if you can place a picture instead of a simple text notification, yes you can. Again, you will have to use echo statement to output HTML code which will show an image:

echo '<img src="http://www.domain.com/image.jpg" />';

We hope that this code will help you create custom notifications and make your WordPress experience even better. How do you like custom post notifications?

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

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