How can i add some static text above the editor?

I created a custom post type and i want to display some text on the editor page below the title and above the text editor. How can i do this?

I tried using add_meta_box, but i wasn’t able to move it above the editor.

4 s
4

The best way would be using JavaScript to inject the element.

Here’s the gist of the markup for that page:

<div id="poststuff">

    <div id="post-body" class="metabox-holder columns-2">
        <div id="post-body-content">
            <div id="titlediv">
                ... other stuff ...
            </div>

            <div id="postdivrich" class="postarea">
                ... other stuff ...
            </div>
        </div>
    </div>
</div>

The titlediv is the title. The postdivrich is the content editor. You want to insert something between them. Using jQuery, this is pretty easy. Just tell it to insert your markup after the titlediv:

jQuery(function($) {
    var text_to_insert = "This is some text you'll throw between the title and editor.";

    $('<p>' + text_to_insert + '</p>').insertAfter('#titlediv')
});

Here is the result of using that exact code on my own site:

Inserting text before the editor.

Leave a Comment