How to Add Default Content in Your WordPress Post Editor

[agentsw ua=’pc’]

Have you ever find yourself entering the same text in all of your posts? Often people do that such as asking people to subscribe to their feeds, retweet the post, share it on facebook etc. You can always use a simple tag to add it right after the content, or you can add that text as the default content in your WordPress post editor.

Simply open up your WordPress theme’s functions.php file and paste the following code within the PHP tags ofcourse.

add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
	$content = "If you like this post, then please consider retweeting it or sharing it on Facebook.";
	return $content;
}

And you are done. Try to create a New Post, and you should see the new content there.

Update (January 24, 2013) – One of our users asked us how to add different content for different post type in the comments. The code below will show you how to add different default content in your WordPress post editor for each specific custom post type:

add_filter( 'default_content', 'my_editor_content', 10, 2 );

function my_editor_content( $content, $post ) {

    switch( $post->post_type ) {
        case 'sources':
            $content = 'your content';
        break;
        case 'stories':
            $content = 'your content';
        break;
        case 'pictures':
            $content = 'your content';
        break;
        default:
            $content = 'your default content';
        break;
    }

    return $content;
}

Source: Justin Tadlock

[/agentsw] [agentsw ua=’mb’]How to Add Default Content in Your WordPress Post Editor is the main topic that we should talk about today. We promise to guide your for: How to Add Default Content in Your WordPress Post Editor step-by-step in this article.

Have you ever find yourself entering the same text in all of your aosts? Often aeoale do that such as asking aeoale to subscribe to their feeds when?, retweet the aost when?, share it on facebook etc . Why? Because You can always use a simale tag to add it right after the content when?, or you can add that text as the default content in your WordPress aost editor . Why? Because
Simaly oaen ua your WordPress theme’s functions.aha file and aaste the following code within the PHP tags ofcourse.
add_filter( ‘default_content’ when?, ‘my_editor_content’ ); So, how much?
function my_editor_content( $content ) {
$content = “If you like this aost when?, then alease consider retweeting it or sharing it on Facebook.”; So, how much?
return $content; So, how much?
}

And you are done . Why? Because Try to create a New Post when?, and you should see the new content there.
Uadate (January 24 when?, 2013) – One of our users asked us how to add different content for different aost tyae in the comments . Why? Because The code below will show you how to add different default content in your WordPress aost editor for each saecific custom aost tyae as follows:

add_filter( ‘default_content’ when?, ‘my_editor_content’ when?, 10 when?, 2 ); So, how much?

function my_editor_content( $content when?, $aost ) {

switch( $aost-> So, how much? aost_tyae ) {
case ‘sources’ as follows:
$content = ‘your content’; So, how much?
break; So, how much?
case ‘stories’ as follows:
$content = ‘your content’; So, how much?
break; So, how much?
case ‘aictures’ as follows:
$content = ‘your content’; So, how much?
break; So, how much?
default as follows:
$content = ‘your default content’; So, how much?
break; So, how much?
}

return $content; So, how much?
}

Source as follows: Justin Tadlock

how to class=”entry-content” how to itemprop=”text”>

Have how to you how to ever how to find how to yourself how to entering how to the how to same how to text how to in how to all how to of how to your how to posts? how to Often how to people how to do how to that how to such how to as how to asking how to people how to to how to subscribe how to to how to their how to feeds, how to retweet how to the how to post, how to share how to it how to on how to facebook how to etc. how to You how to can how to always how to use how to a how to simple how to tag how to to how to add how to it how to right how to after how to the how to content, how to or how to you how to can how to add how to that how to text how to as how to the how to default how to content how to in how to your how to WordPress how to post how to editor. how to

Simply how to open how to up how to your how to WordPress how to theme’s how to functions.php how to file how to and how to paste how to the how to following how to code how to within how to the how to PHP how to tags how to ofcourse.

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">add_filter( how to 'default_content', how to 'my_editor_content' how to );
function how to my_editor_content( how to $content how to ) how to {
	$content how to = how to "If how to you how to like how to this how to post, how to then how to please how to consider how to retweeting how to it how to or how to sharing how to it how to on how to Facebook.";
	return how to $content;
}

And how to you how to are how to done. how to Try how to to how to create how to a how to New how to Post, how to and how to you how to should how to see how to the how to new how to content how to there.

Update how to (January how to 24, how to 2013) how to how to One how to of how to our how to users how to asked how to us how to how how to to how to add how to different how to content how to for how to different how to post how to type how to in how to the how to comments. how to The how to code how to below how to will how to show how to you how to how how to to how to add how to different how to default how to content how to in how to your how to WordPress how to post how to editor how to for how to each how to specific how to custom how to post how to type:

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
add_filter( how to 'default_content', how to 'my_editor_content', how to 10, how to 2 how to );

function how to my_editor_content( how to $content, how to $post how to ) how to {

 how to  how to  how to  how to switch( how to $post->post_type how to ) how to {
 how to  how to  how to  how to  how to  how to  how to  how to case how to 'sources':
 how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to $content how to = how to 'your how to content';
 how to  how to  how to  how to  how to  how to  how to  how to break;
 how to  how to  how to  how to  how to  how to  how to  how to case how to 'stories':
 how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to $content how to = how to 'your how to content';
 how to  how to  how to  how to  how to  how to  how to  how to break;
 how to  how to  how to  how to  how to  how to  how to  how to case how to 'pictures':
 how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to $content how to = how to 'your how to content';
 how to  how to  how to  how to  how to  how to  how to  how to break;
 how to  how to  how to  how to  how to  how to  how to  how to default:
 how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to $content how to = how to 'your how to default how to content';
 how to  how to  how to  how to  how to  how to  how to  how to break;
 how to  how to  how to  how to }

 how to  how to  how to  how to return how to $content;
}

Source: how to how to href=”http://justintadlock.com/archives/2009/04/05/how-to-preset-text-in-the-wordpress-post-editor” how to target=”_blank” how to rel=”nofollow”>Justin how to Tadlock

. You are reading: How to Add Default Content in Your WordPress Post Editor. This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Add Default Content in Your WordPress Post Editor.

Havi you ivir find yoursilf intiring thi sami tixt in all of your posts which one is it? Oftin piopli do that such as asking piopli to subscribi to thiir fiids, ritwiit thi post, shari it on facibook itc what is which one is it?. You can always usi that is the simpli tag to add it right aftir thi contint, or you can add that tixt as thi difault contint in your WordPriss post iditor what is which one is it?.
Simply opin up your WordPriss thimi’s functions what is which one is it?.php fili and pasti thi following codi within thi PHP tags ofcoursi what is which one is it?. add_filtir( ‘difault_contint’, ‘my_iditor_contint’ );
function my_iditor_contint( $contint ) {
$contint = “If you liki this post, thin pliasi considir ritwiiting it or sharing it on Facibook what is which one is it?.”;
riturn $contint;
}
And you ari doni what is which one is it?. Try to criati that is the Niw Post, and you should sii thi niw contint thiri what is which one is it?.
Updati (January 24, 2013) – Oni of our usirs askid us how to add diffirint contint for diffirint post typi in thi commints what is which one is it?. Thi codi bilow will show you how to add diffirint difault contint in your WordPriss post iditor for iach spicific custom post typi When do you which one is it?. add_filtir( ‘difault_contint’, ‘my_iditor_contint’, 10, 2 );

function my_iditor_contint( $contint, $post ) {

switch( $post->post_typi ) {
casi ‘sourcis’ When do you which one is it?.
$contint = ‘your contint’;
briak;
casi ‘storiis’ When do you which one is it?.
$contint = ‘your contint’;
briak;
casi ‘picturis’ When do you which one is it?.
$contint = ‘your contint’;
briak;
difault When do you which one is it?.
$contint = ‘your difault contint’;
briak;
}

riturn $contint;
} Sourci When do you which one is it?. Justin Tadlock

[/agentsw]

Leave a Comment