How to Add Reminders/Notes to New Post Meta Boxes

I have a multi-author website and I use the WyPiekacz plugin to require that authors add 1-5 tags, select only a single category, and include a featured image (and require minimum dimensions for the featured image).

WyPiekacz also can restrict title/content min/max length. WyPiekacz is great, but it will only tell the author after they have done something wrong, not let them know the requirements before they make a mistake.

I would like to be able to add a note/reminder to each meta box to guide the author. Currently I have written the notes directly into the wordpress files. Here is a screen shot of my addition.

Tags Meta Box Note WordPress

Featured image meta box located in wp-admin/includes/post.php
Tags and categories boxes located in wp-admin/includes/meta-boxes.php

I would like to include these notes in the functions.php file or as settings in WyPiekacz.

I am not a coder, so any assistance would be greatly apprectiated.

3 s
3

You should never edit the core files of WordPress.

Instead you should only ever edit Plugin files and or Theme files (Plugins or Themes folder)

One of the easiest was to achieve this would be via jQuery;

jQuery('<div/>', {
    id: 'your-note',
    text: 'Add up to 5 tags...etc'
}).appendTo('#tagsdiv-post_tag .inner');

Save the above into a alerts.js file (or name it whatever you want). Place this file in your theme folder /theme_name/js/ for organizational purposes.

Then in your functions.php file paste;

function load_my_alerts(){
      wp_register_script( 
        'my_alerts', 
        get_template_directory_uri() . '/js/alerts.js', 
        array( 'jquery' )
    );
    wp_enqueue_script( 'my_alerts' );
}
add_action('admin_enqueue_scripts', 'load_my_alerts');

This will enqueue and load your alerts.js file only in the admin section of your site and as such it will then apply your jQuery by appending a div with an ID selector of your choice followed by your desired text.

This part ('<div/>', { will create a self-enclosed div for you, i.e. <div id="your-note">your note here...</div>

UPDATE

You might in effect try this as a template for multiple items;

jQuery(document).ready(function($){

$('<div/>', {
    id: 'xxx',
    text: 'yyy'
}).appendTo('#tagsdiv-post_tag .inner');

$('<div/>', {
    id: 'aaa',
    text: 'bbb'
}).appendTo('#some_other_element .example');

// etc...

});

Leave a Comment