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 would like to add a custom Meta Box with Html content in the screens New and Edit Posts/Pages (/wp-admin/post.php?post=POST_ID&action=edit), so that I could display a list of editorial guidelines for my editors to follow.

Or, even better, is there a plugin to do this so that I don't have to go into the code every time we want to edit these guidelines?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Don't know any plugin for that. But it can be solved creating a custom plugin with the Settings API and a Custom Meta Box.

Adding a RichText Editor in the Settings Page

/wp-admin/options-general.php

<?php
/* Plugin Name: Custom Editor in Settings Page */

add_action( 'admin_init', 'register_settings_wpse_57647' );

# Register settings
function register_settings_wpse_57647() 
{
    register_setting( 
        'general', 
        'html_guidelines_message',
        'esc_html'
    );
    add_settings_section( 
        'site-guide', 
        'Publishing Guidelines', 
        '__return_false', 
        'general' 
    );
    add_settings_field( 
        'html_guidelines_message', 
        'Enter custom message', 
        'print_text_editor_wpse_57647', 
        'general', 
        'site-guide' 
    );
}    

# Print settings field content
function print_text_editor_wpse_57647() 
{
    $the_guides = html_entity_decode( get_option( 'html_guidelines_message' ) );
    echo wp_editor( 
        $the_guides, 
        'sitepublishingguidelines', 
        array( 'textarea_name' => 'html_guidelines_message' ) 
    );
}

Results in:
resulting settings

Adding a Meta Box to Posts/Pages

This will print the option saved in the Settings page.

add_action( 'add_meta_boxes', 'add_custom_box_wpse_57647' );

# Add Meta Boxes
function add_custom_box_wpse_57647() 
{
    foreach( array( 'post', 'page' ) as $cpt )
        add_meta_box( 
            'mb_wpse_57647',
            __( 'Additional Guidelines', 'this_plugin_or_theme_textdomain' ),
            'inner_custom_box_wpse_57647',
            $cpt,
            'side',
            'high'
        );
}

# Prints the box content
function inner_custom_box_wpse_57647( $post ) 
{
    global $current_user;
    get_currentuserinfo();
    $the_guides = html_entity_decode( get_option ( 'html_guidelines_message' ) );
    echo '<h2>Howdy, ' . $current_user->display_name . '</h2>';
    echo "<div>$the_guides</div><br style='clear:both' />";
}

Results in:
resulting meta box

share|improve this answer

I think what you are looking for is a metabox plugin... That way you would be able to add html boxes in post/edit screens

http://wordpress.org/extend/plugins/meta-box/

share|improve this answer
1  
Ehm, this plugin ask you to define the box by code, it's exactly what I don't want to do. –  Bakaburg Jul 6 '12 at 17:59

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.