Many times we need to set the default content for the WordPress article editor, such as the usual beginning or article attention to put in, this article teaches you to the WordPress editor to set the default content.
/** *wordpress Set default content to the story editor *http://www.endskin.com/default-content-title/*/function Bing_default_ Content () { return ' default contents to set ';} Add_filter (' default_content ', ' bing_default_content ');
You can also set the default caption:
/** *wordpress Sets the default caption for the story editor *http://www.endskin.com/default-content-title/*/function Bing_default_title ( { return ' default caption to set ';} Add_filter (' Default_title ', ' bing_default_title ');
Add the top two pieces of code and open the Publish article interface by default this is the case:
But what if the site has a lot of custom article types, and each article type wants to set the default content separately?
In fact, you just need a simple judgment, and then return it separately:
/** *wordpress Custom article types set default content to the editor *http://www.endskin.com/post-default-content-title/*/function Bing_ Default_content ($content, $post) { switch ($post->post_type) {case ' post ': $content = ' The default content of the article '; break; Case ' page ': $content = ' default content of the page '; break; Case ' pic ': $content = ' Picture (custom article type) ' default content '; break; } return $content;} Add_filter (' default_content ', ' bing_default_content ', 10, 2);
The default title is similar, just change the default_content hook to Default_title.