Snippet content
Welcome to WordPress. This is your first post.
我想在Wordpress单个博客文章标题之后和单个博客内容之前添加一小段代码。
我知道有the_title和the_content WordPress过滤器。使用这些过滤器的问题是将它们附加(或前置)在其内部。
add_filter('the_title', array($this, 'add_snippet') );
public function add_snippet($title) {
$snippet_html = '
return $title . $snippet_html;
}
将输出:
” the_content”过滤器也是如此:
add_filter('the_content', array($this, 'add_snippet') );
public function add_snippet($content) {
$snippet_html = '
return $snippet_html . $content;
}
将输出:
Welcome to WordPress. This is your first post.
是否有任何WP方法可获得所需的输出?
Snippet content