Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
please don't forget to accept answers which solve your problem. It credits those who help you, and also takes it off the unanswered pile. –  Stephen Harris Apr 15 '12 at 1:07

2 Answers 2

up vote 6 down vote accepted

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...

});
share|improve this answer
    
Thanks, but it doesn't seem to be working. I have done exactly what you mentioned, but the message did not show up. Do I need to do the complete jQuery part of the code for each meta box? or is there a more direct and efficient way? –  Travis Pflanz Apr 14 '12 at 21:02
    
That's pretty direct and efficient already - since what you are looking to do is essentially DOM manipulation. The alternative is to either use PHP DOMDocument manipulation or something like PHP Simple DOM Parser but the latter means you need to add-on a library, not to mention then write the code to manipulate the DOM. So unless anyone else knows of an easier way to hook a message into the Tags metabox that's simpler than using jQuery then that's probably the best bet. (IMO) –  userabuser Apr 14 '12 at 21:04
    
@TravisPflanz View the source whilst in your admin area and make sure your alerts.js file is loaded. If it does not exist then there is an error with your input. If it does exist, try updating with the code snippet above. jQuery(document).ready(function($){ //do your stuff here }); –  userabuser Apr 14 '12 at 21:06
    
Thanks, The UPDATE part of the answer worked. Being that I also included a link to a help page, "text" was changed to "html". –  Travis Pflanz Apr 15 '12 at 4:39

First I'd like to re-iterate @userabuser. You should never edit the core files of WordPress. In fact, you should avoid editing plug-ins and themes (use a child-theme instead) since changes are lost on an update, and you should update!

I would follow the method outlined in these questions:

and de-register the existing metabox used (I think as @userabuser uses, the ID is #tagsdiv-post_tag). Then re-register it, allowing you to create a function which defines its insides as explained in the above posts.

For your purposes however, the function you want to mimic is post_tags_meta_box(), found here: http://core.trac.wordpress.org/browser/tags/3.3/wp-admin/includes/meta-boxes.php#L265

Simply use the contents of that function in your own custom call back, and edit to display your messages.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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