Sunday, November 30, 2014

Set Default Content in WordPress Editor for All Posts

As, We know that WordPress comes with a hook called default_ content, which allows us to set default content in our WordPress post editor or create the post page. This would be very helpful if we are repeatedly adding same content in all of our posts.

For Example :- By asking people to share the post on Facebook or subscribe to RSS feeds.

WordPress Editor


Check out the below code to explaing your custom default content,

//Set default content in your WordPress post editor

add_filter( 'default_content', 'ccw_set_default_content', 10, 2 );
function ccw_set_default_content( $content, $post ){
    if ( 'post' !== $post->post_type ){
        return $content;
    }
    return 'This is the default content.';
}

0 comments:

Post a Comment