X

How To Display Random Messages of Encouragement on Post Creation

Snippets by IsItWP

Are you looking for a way to display random messages of encouragement when a post is created? This snippet will allow you to display messages of encouragement to an author when they create a new post. The messages are displayed in the title field and the content field of new posts.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin. You can edit the arrays of messages to suit your needs.

add_filter( 'default_content', 'writingEncouragement' );
function writingEncouragement( $content ) {
			global $post_type;
			if($post_type == "post"){
			$encArray = array( "Welcome! Please write a nice and informative page or post!", 
			"Now I know this will be some great piece you're going to write!",
			"<h1>Don't procrastinate!</h1>",
			"Finally started, huh? Okay then!",
			"Blah blah blah. Why don't you write something good this time?",
			"You were just SO GOOD last time, I hope you measure up now too",
			"Error 404.... Just kidding",
			"If you have an SEO plugin, don't forget to add the meta title and meta description information",
			"You are now participating on what is called \"on-site SEO \" where you create useful content, put keywords into the URL and optimize your meta information",
			"This little piece of code can be used to create a wordpress signature or to automatically populate advertisement code"
									);
			$content = $encArray[array_rand($encArray)];
	return $content;
			}
}

function title_text_input( $title ){
    	$title = array( "Enter a GOOD, CREATIVE Title!",
			"404 Post Not Found, I guess you can just rewrite it",
			"Title rich in KEYWORDS goes here",
			"Enter Title",
			"Enter Writing Mode",
			"How To: Write a GOOD post",
			"Top 10 whatever"
			);
			$title = $title[array_rand($title)];
	return $title;
}
add_filter( 'enter_title_here', 'title_text_input' );

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 30 Ways to Make Money Online Blogging (On the Side) and 100+ interesting WordPress stats and facts.

Comments   Leave a Reply

  1. Creative, Fun, Surefire Way to Get the Attention of Blog Authors... May 22, 2012 at 11:00 am

    […] trick (found at wpsnipp) works by filling in the Title Box and/or the Editor Box with predefined text. And so when an […]

Add a Comment Cancel reply

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!