wordpress <?php the_content,在Wordpress单个博客文章中的"the_title"之后和"the_content"之前放置一个代码段 - WordPress - src...

我想在Wordpress单个博客文章标题之后和单个博客内容之前添加一小段代码。

我知道有the_title和the_content WordPress过滤器。使用这些过滤器的问题是将它们附加(或前置)在其内部。

add_filter('the_title', array($this, 'add_snippet') );

public function add_snippet($title) {

$snippet_html = '

Snippet content
';

return $title . $snippet_html;

}

将输出:

Hello world!

Snippet content

” the_content”过滤器也是如此:

add_filter('the_content', array($this, 'add_snippet') );

public function add_snippet($content) {

$snippet_html = '

Snippet content
';

return $snippet_html . $content;

}

将输出:

Snippet content

Welcome to WordPress. This is your first post.

是否有任何WP方法可获得所需的输出?

Hello world!

Snippet content

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值