Insert text in wordpress post editor

April 18, 2009 · Print This Article

Do you always insert the same text on all your posts, for exemple to tell people to subscribe to your rss feed? If yes, you should definitely set up wordpress to have it automatically inserted in the editor.

There are built-in action and filter hooks that allow us to change things. We’ll be showing you how to use a simple filter to preset text in the WordPress post/page editor. This technique will work with both the visual and HTML editor.

We’ve established that you shouldn’t edit core files. Then what should we edit? Our theme’s functions.php file. Or, we could go through the process of making a plugin, but this is pretty simple stuff.

Just open your functions.php file in your favorite text editor, and paste the following code:

add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
$content = "This is some custom content I'm adding to the post editor because I hate re-typing it.";
return $content;

It’s as simple as that. Just a few lines of code. You could even add in some XHTML if you want.

This will only add your text to new posts. It will not add it to posts that have already been written or saved. And, you can always delete it when writing the post if it’s not needed.

Your choice for site templates and wordpress themes


Got something to say?

You must be logged in to post a comment.