How to add some custom HTML to the edit posts page

On the wordpress admin edit posts page, I want to display some custom content and script, underneath the meta box.

I want to hand code this as the various plugins I could use (advanced custom fields for instance) take too much control away, and I don’t need an actual field to be saved.

Read More

So for example, I want to add this to the edit posts page:

<div class='mydiv'>
  <img src='someImage.png' alt='someImage'/>
  <script type='text/javascript'>alert('hello world!');</script>
</div>

That’s pretty much it. Nothing fancy or that contains any editable content.

What hook or function do I need to use to achieve this?

Any help greatly appreciated

Related posts

Leave a Reply

1 comment

  1. As found here:

    http://codex.wordpress.org/Function_Reference/add_meta_box

    /**
     * Calls the class on the post edit screen
     */
    function call_someClass() 
    {
        return new someClass();
    }
    if ( is_admin() )
        add_action( 'load-post.php', 'call_someClass' );
    
    /** 
     * The Class
     */
    class someClass
    {
        const LANG = 'some_textdomain';
    
        public function __construct()
        {
            add_action( 'add_meta_boxes', array( &$this, 'add_some_meta_box' ) );
        }
    
        /**
         * Adds the meta box container
         */
        public function add_some_meta_box()
        {
            add_meta_box( 
                 'some_meta_box_name'
                ,__( 'Some Meta Box Headline', self::LANG )
                ,array( &$this, 'render_meta_box_content' )
                ,'post' 
                ,'advanced'
                ,'high'
            );
        }
    
    
        /**
         * Render Meta Box content
         */
        public function render_meta_box_content() 
        {
            ?>
            <div class='mydiv'>
              <img src='someImage.png' alt='someImage'/>
              <script type='text/javascript'>alert('hello world!');</script>
            </div>
            <?php
    
        }
    }