A couple of new hooks in WordPress 3.5 make it much simpler to hook in below both the post title box and the post editor. You can then use these functions to hook into these locations for whatever purpose you need.
In this quick example, I’m going to demonstrate how to use them to display simple messages, which can be very useful for displaying instructions on a client site, for example.
function below_the_title() {
echo '<h3>Make sure your title is punchy and relevant to the content.</h3>';
}
add_action( 'edit_form_after_title', 'below_the_title' );
function below_the_editor() {
echo '<h4>Now remember to add in your tags, categories and featured image!</h4>';
}
add_action( 'edit_form_after_editor', 'below_the_editor' );
The result of using functions like this can be seen in the screenshot below:
Dave Clements has been building websites for close to a decade and in 2010, he formalised that by starting his own company, The UK Edge. He now works on a variety of web projects, from simple tasks like installing a new WordPress site, to consulting on problems, or redesigning his clients' sites. He also runs Do It With WordPress, a site dedicated to providing free tutorials on WordPress.
When he's not building your new website, you can find Dave eating Wheat Thins, spending time with friends and family, watching Indie films, fostering kittens from the local Humane Society, listening to some dubstep, dance and electronic rock, and exploring the world.
Dave I think this could be really useful for a subtitle. Could you give an example? Not sure how you would create the form element for the subtitle field and then output it in a theme.
That’s something else entirely. You’d need to use custom meta to save the information to the post and then output it to the theme using get_post_meta. This is simply for displaying messages (or performing other actions with the hook) above or below the editor in the dashboard only.
Ahhh, well that you could certainly do. You might need to do some research to do it, but yes, you can use this hook to place the metabox in the desired location and then call upon that information in the theme.
December 17, 2012 at 10:11 am
Dave I think this could be really useful for a subtitle. Could you give an example? Not sure how you would create the form element for the subtitle field and then output it in a theme.
December 18, 2012 at 8:28 am
That’s something else entirely. You’d need to use custom meta to save the information to the post and then output it to the theme using get_post_meta. This is simply for displaying messages (or performing other actions with the hook) above or below the editor in the dashboard only.
December 18, 2012 at 9:35 am
I suspected it might require a metabox but I was hoping to use this hook to place the metabox in this location.
December 18, 2012 at 11:19 am
Ahhh, well that you could certainly do. You might need to do some research to do it, but yes, you can use this hook to place the metabox in the desired location and then call upon that information in the theme.
December 20, 2012 at 6:22 pm
Very interesting. Is there a way to make it closer to the title box
December 29, 2012 at 8:07 am
Of course, using CSS you could put a negative top margin, or reduce the bottom margin on the title box.