Most of the bloggers write the blogs in a certain format or at-least have a common signature or a punch line in every post on their blog. For example in my blog posts I always end the posts with

Stay Digified!!

Sachin Khosla

So what if we can automate that type of text such that it shows up automatically whenever you start writing a new post ? Yes, that will be something awesome, hence in this blog post I am going to show you how you can do that in your blog. I am sure there must be some plugins out already for this trick, but my aim here is to make you understand how simple it is to do your own thing 🙂

Since you know WordPress comes with lot of hooks and filters to make the development process easier. Hence we are going to use a filter which will allow us to populate some pre-defined text while creating a new post. Now let us see how to go about it.

Open functions.php which is present in the themes folder of your blog and copy the following code at the end of the file.

 * Add a filter called default_content
add_filter('default_content', 'add_pre_populated_content');
 * function will get called by the filter defined above
function add_pre_populated_content( $content ) {
        // you can change the content as per your requirement
	$content = "<p>Stay Digified!!<br/>Sachin Khosla</p>"; 
	return $content;

As you can see the we have added a filter called “default_content” in WordPress which is used when you hit “Add New Post” in your WordPress Admin dashboard. You can put as much content as you want to add as per your requirement. I told you already that it’s simple, right ? So go ahead and add this code snippet in your blog and enjoy.

Stay Digified !!
Sachin Khosla

Share this post: