wordpress默认密码_如何在WordPress帖子编辑器中添加默认内容

wordpress默认密码

Have you ever find yourself entering the same text in all of your posts? Often people do that such as asking people to subscribe to their feeds, retweet the post, share it on facebook etc. You can always use a simple tag to add it right after the content, or you can add that text as the default content in your WordPress post editor.

您是否发现自己在所有帖子中都输入了相同的文字? 人们经常这样做,例如要求人们订阅他们的提要,转发信息,在Facebook上分享等等。您始终可以使用简单的标签在内容之后立即添加它,也可以将该文本添加为​​默认内容您的WordPress帖子编辑器。

Simply open up your WordPress theme’s functions.php file and paste the following code within the PHP tags ofcourse.

只需打开WordPress主题的functions.php文件并将以下代码粘贴到CoursePHP标签中即可。

add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
	$content = "If you like this post, then please consider retweeting it or sharing it on Facebook.";
	return $content;
}

And you are done. Try to create a New Post, and you should see the new content there.

您完成了。 尝试创建一个新帖子,您应该在那里看到新内容。

Update (January 24, 2013) – One of our users asked us how to add different content for different post type in the comments. The code below will show you how to add different default content in your WordPress post editor for each specific custom post type:

更新(2013年1月24日) –我们的一位用户问我们如何在评论中为不同的帖子类型添加不同的内容。 下面的代码将向您展示如何在WordPress帖子编辑器中为每种特定的自定义帖子类型添加不同的默认内容:


add_filter( 'default_content', 'my_editor_content', 10, 2 );

function my_editor_content( $content, $post ) {

    switch( $post->post_type ) {
        case 'sources':
            $content = 'your content';
        break;
        case 'stories':
            $content = 'your content';
        break;
        case 'pictures':
            $content = 'your content';
        break;
        default:
            $content = 'your default content';
        break;
    }

    return $content;
}

Source: Justin Tadlock

资料来源: 贾斯汀·塔德洛克(Justin Tadlock)

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-add-default-content-in-your-wordpress-post-editor/

wordpress默认密码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值