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

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

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.

share|improve this answer
    
Thanks, its fine for me, but you have to admit, an action to insert some content or something else like that would be better:) –  passatgt Aug 8 '12 at 19:36
    
Might need to add a patch for that :-) Thanks. –  EAMann Aug 8 '12 at 19:55
add comment

new hooks for the add/edit post screen: edit_form_after_title

add_action( 'edit_form_after_title', 'myprefix_edit_form_after_title' );

function myprefix_edit_form_after_title() {
echo '<h2>This is edit_form_after_title!</h2>';
}
share|improve this answer
add comment

To anyone with this problem, check this post: More hooks on the edit screen It allows to insert custom content by new native Wordpress hook, which is by far more stable sollution.

Worked for me!

share|improve this answer
add comment

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.