WordPress is an open source project and is free .It is a content-management system(CMS) based on PHP and MySQL. It is the most popular blogging system in use on the Web. It has a web template system using a template processor. Here is how to add a default content in WordPress.
default_content runs when a post is loaded into the editor. You must have found yourself entering the same text in all your posts. Peopke often do that such as asking people to subscribe to their feeds and sharing it on facebook, etc .
1. You can do this by adding a simple tag at right after the content , or you can add that text as the default content in your WordPress post editor. Open your WordPress theme’s function.php file and paste the following snippet within the PHP tags of course. This is the base code:
add_filter(‘default_content’,’my_editor_content’);
function my_editor_content($content){
$content = “If you like this post, then please consider share it on Facebook.”;
return $content; }
Modifications include:
addfilter(‘default_content’,’my_editor_content’);
function my_editor_content($content){
if(‘source’==get_post_type()) {
$content =”Please insert an image of the document in this area. If there is no image then please descript the document in detail.”;
return $content;
}elseif ( ‘stories’ == get_post_type()) {
$content = “Please write your reminiscences, recollections, memories and remembrances in this area.”;
return $content;
}elseif ( ‘pictures’ == get_post_type()) {
$content =”Please insert an image of a photograph into this area.”;
return $content;
}else {
$content=”default!;
return $content;
};}
2. Using a second parameter $post and check $post- >post_type alongside a switch. Work with if else is very easy and nice etc.
add_filter( ‘default_content’,’my_editor_content’,10,2);
function my_editor_contents( $content, $post) {
switch($post- >post_type) {
case ‘source’:
$contents= ‘Enter your content’;
break;
case ‘stories’:
$contents= ‘Enter your content’;
break;
case ‘pictures’:
$contents= ‘Enter your content’;
break;
default:
$contents= ‘Enter your default content’;
break;
}
return $content;
}
3. You can apply conditioals to a specific post type also. You just need to write the following snippet:
add_filter(‘default_content’,’my_editor_content’);
function my_editor_content($content) {
global $post_type;
if (‘post’ == $post_type) {
$content = “If you enjoyed this post, make sure to <a href = “https://feeds.feedburner.com/WPMayor”>suscribe to WPMayor’s RSS feed</a>.”;
return $content;
}
This plugin sets the title and body of new blog posts so that when the post contain the same content then each content doesn’t need to be typed again and again. WordPress Multisite lets you have default content for One Post, Page and comment under the Network settings.
WordPress has grown to be the largest self-hosted blogging tool in the world, which is used by millions of sites .WordPress is the most popular CMS in use today.WordPress users may install and switch between themes. Themes allow users to change the functionality and look of a WordPress website.