加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > CMS系统 > wordpress > 正文

wordpress编辑器自动填充默认的内容

发布时间:2020-12-14 14:35:12 所属栏目:wordpress 来源:网络整理
导读:如果你经常写同样的帖子(文章、列表、代码片段等),我们无需每次敲打同样的内容,下面超级简单的代码片段可以实现非常有用的预填充的WordPress编辑一些自定义的内容。 在你的主题的 functions.php文件中复制以下代码: add_filter( 'default_content','pu_de

如果你经常写同样的帖子(文章、列表、代码片段等),我们无需每次敲打同样的内容,下面超级简单的代码片段可以实现非常有用的预填充的WordPress编辑一些自定义的内容。

在你的主题的 functions.php文件中复制以下代码:

add_filter( 'default_content','pu_default_editor_content' );

function pu_default_editor_content( $content ) {

global $post_type;

switch( $post_type )

{

case 'post':

$content = 'Default content for blog posts.';

break;

case 'page':

$content = 'Default content for pages.';

break;

case 'portfolio':

$content = 'Default content for your portfolio pages.';

break;

case 'products':

$content = 'Default content for blog posts.';

break;

}

return $content;

}

根据自己填充的需要编辑 $content变量的内容。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读