Skip to content

Android Tutorial Station

New hooks from the WordPress 3.5 post editor

One of the novelties that WordPress 3.5 brings are the hooks for the post editor , specifically: edit_form_after_title and edit_form_after_editor .

What is a hook?

A software hook is a “hook” that serves as a connector to modify some aspect of the original program without the need to edit or reprogram the original files.

How does this new wordpress hook work?

This new hook offers us the possibility to interact with the post editor, both after the title text box and after the editor, how you can already deduce from the name of the hooks edit_form_after_title (to interact after the title box) and edit_form_after_editor (to interact after the editor box).

Many of you will be wondering how useful you can give these new hooks, because it has many uses, you just have to give it imagination, but I will give you an example of use that came in handy for one of my blogs. With this hook, I added some reminders to publishers that sometimes forgot to add tags or add the keyword to the title of the article.

To make this reminder we will use a code which we will paste in the functions.php file

  //Personalizar editor de WordPress v3.5 con mensajes add_action( 'edit_form_after_title', 'myprefix_edit_form_after_title' ); function myprefix_edit_form_after_title() {   echo '<h2>¡Recuerda usar la palabra clave principal en el título!</h2>'; }  add_action( 'edit_form_after_editor', 'myprefix_edit_form_after_editor' ); function myprefix_edit_form_after_editor() {   echo '<h2>¡Antes de publicar añade tags!</h2>'; } 

With this code we will be able to add our reminders to our editors. It is a very simple example and also shows us how to use any hook in general since the mechanics are the same.

As a tip, I would tell you that if you are going to make use of several hooks and therefore use a large number of lines of code, it might be a good idea to move the hooks code to a separate php file and use in the functions.php the include () function to include this file with the hook code.

No comments yet.

Leave a Reply

Your email address will not be published.

Comments (0)