The way to set default content in WordPress article editor, WordPress Editor
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.
Articles you may be interested in:
- Tips for customizing the background Management interface color scheme in WordPress
- Implementation of correlation function parsing for sending HTTP requests in WordPress
- PHP functions for creating and getting sidebar in WordPress
- How to use the function of adding and executing actions in WordPress
http://www.bkjia.com/PHPjc/1086652.html www.bkjia.com true http://www.bkjia.com/PHPjc/1086652.html techarticle in the WordPress article editor to set the default content method, WordPress editor Many times we need to give the WordPress article editor to set the default content, such as the usual opening ...