Many times we need to set default content for WordPress article editor, such as starting with commonly used Or put in the article notes, and this article will teach you how to set the default content for the WordPress editor.
/** *WordPress 给文章编辑器设置默认内容 *http://www.endskin.com/default-content-title/ */ function Bing_default_content(){ return '要设置的默认内容'; } add_filter( 'default_content', 'Bing_default_content' );
You can also set a default title:
/** *WordPress 给文章编辑器设置默认标题 *http://www.endskin.com/default-content-title/ */ function Bing_default_title(){ return '要设置的默认标题'; } add_filter( 'default_title', 'Bing_default_title' );
After adding the above two pieces of code, the default article publishing interface will look like this:
But what if the website has many custom article types and you want to set default content for each article type separately?
In fact, you only need to make a simple judgment and then return separately:
/** *WordPress 自定义文章类型分别给编辑器设置默认内容 *http://www.endskin.com/post-default-content-title/ */ function Bing_default_content( $content, $post ){ switch( $post->post_type ){ case 'post': $content = '文章的默认内容'; break; case 'page': $content = '页面的默认内容'; break; case 'pic': $content = '图片(自定义的文章类型)的默认内容'; break; } return $content; } add_filter( 'default_content', 'Bing_default_content', 10, 2 );
The default title is similar, just replace the default_content hook with default_title.