#14: the_editor_content

The the_editor_content filter makes it possible for you to pre-fill the content editor in the post editing screen.

It is evaluated in the _WP_Editors::editor() method in wp-includes/class-wp-editor.php. The _WP_Editors class is instantiated via wp_editor() located in wp-includes/general-template.php.

the_editor_content‘s single argument is the editor content string, empty by default.

Note: to avoid a situation where your content ends up duplicating every time you update the post, you should check if the editor content is empty before returning the filtered version of it. We’ll cover this in the example.


Let’s say you run a site that documents a lot of very similar things, like say, filters. It can be kind of a drag to write out and/or copy/paste the same template into the editor over and over, so the following will show you how to inject a post template into the editor prior to the first save.

View the code example on Gist.

Have a suggested improvement? You can fork the Gist and comment back with the link. If all is agreeable, I’ll merge in your changes. Crowd-sourced documentation FTW!

Leave a Reply

Your email address will not be published. Required fields are marked *