Add text above the WordPress Editor


In this article, we will print a reminder message for the user above the WordPress Editor metabox by hooking into the response generation code at the point right after the post title has been printed at the top of the WordPress editor page in the admin area.

WordPress hooks are defined either as Filters or Actions. When WordPress is processing a request for a page on your web site, it performs a sequence of actions.  Some examples are: loading plugin code, retrieving web page content from the database, and sending the results to the user making the request. WordPress defines hooks at various points of this sequence, these hooks are called Actions. You can register a function to be executed at any one of this points in the timeline of generating a response to a request.

WordPress performs different tasks when generating a front-end web page response than compared to generating a web page in the wp-admin area of the web site.  This article will focus on an action hook that is triggered when WordPress is generating a post editor page.

The code example below can be added to your WordPress theme’s functions.php file for automatic execution.

Print a message over the editor box

The Action hook we will use is called ‘edit_form_after_title’. The code below defines a function that simply echos HTML code. That function is then registered as an Action hook callback function with WordPress in the call to add_action( ). The <div class=”postbox”> HTML element will place text message inside a WordPress styled postbox.

 * Print a reminder about how to add a single spaced line in editor.
function print_reminder() {
	echo <<<ENDTXT
	<div class="postbox">
		<span style="color:red;">
		Hold down Shift and press Enter for single-spaced lines.
		Press Enter by itself for double-spaced lines.
add_action( 'edit_form_after_title', 'print_reminder' );