
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 WP to have it automatically inserted in the editor.

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 WP to have it automatically inserted in the editor.
Really simple: Just open your functions.php file, and paste the following code:
<?php
add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
$content = "If you enjoyed this post, make sure to subscribe to my rss feed.";
return $content;
}
?>
Save the file, and create a new post: The "If you enjoyed this post, make sure to subscribe to my rss feed." text is already in WordPress editor!
Credits goes to Justin Tadlock for this awesome recipe!
27 Responses
Perfect for repetitive text.
Can we use HTML tags in pre-filled text?
Thanks for the tips. I guess this is the way to go if I don’t always want to include some text in the end of the post. With this, the blogger has a choice to delete it or leave it as is.
tnx for this tip! its very useful
@CLAT Guru: Yes, you can preload any text into the text editor using this filter. Just make sure you’re escaping special characters properly (i.e. single or double quotes) so as to be proper PHP strings. I preload a whole bunch of stuff … IMG tags, DIV’s with special class names that I might want to include in each post, etc.
I put together a plugin the other day to take advantage of this – it uses the wordpress visual editor for the default post content, so you can edit html, and insert images and other elements as you would normally in a post. It also handles default post meta.
Default Post Content Plugin
Yeah i just used it.
It’s very useful , thank you .
this post very good…for my forum
This is a perfect
thanks
Wow, this is even better than your last tip about WP Shortcodes. I was using a shortcode to insert the “Get Adobe Acrobat Reader” info, and went one better by editing the quicktags.js file to automatically insert [get] there. This is much better and cleaner.
Great and simple Trick!
Thanks.
Thank you Justin,
Thank you Peter (for Default Post Content Plugin!).
I am using it now, thanks for sahring
great concept. i like the plug-in approach even better because it becomes easier to maintain/change.
// The filter function
function my_the_content($content){
global $post, $wpdb;
return $content.’Subscribe to my RSS … bla … bla … bla’;
}
// Low priority to append last
add_filter(‘the_content’, ‘my_the_content’, 9999);
// So much easier …
Wowwwwwwwwwwwwwwwww, so amazing tip.
Hi! Thanks for the tip! Say if you need to add more text, say, maybe another paragraph of something, how do u go about doing it? Do you just continue from there or I have to add another function?
Thanks!
Anyone know how to do this for a page template? As in I want to create a page template, that when selected, automatically inserts content into the editor — but only for this page template and not all posts/pages…
What is the syntax used to create a link in the php code? I want to turn the RSS in the string into a clickable link but can’t figure out the proper way to do it.
Thanks
Would it be possible to display content only on certain page-templates?
How would the code look like?
Wow this is perfect for a shortcode I was using in all my posts thank you!!
Trackbacks: