追加的内容如何添加点击事件
The awesome part of RSS is that it lets you pull content wherever you want. The bad part, as a publisher, is that the user may be missing out on important information that is on the site but doesn't display in articles. WordPress' hook system to the rescue!
RSS的令人敬畏的部分是它使您可以将内容拉到所需的任何位置。 作为发布者,最糟糕的部分是,用户可能会错过网站上的重要信息,但不会显示在文章中。 WordPress的挂钩系统可助您一臂之力!
PHP (The PHP)
We're going to hook onto the the_content
and the_excerpt_rss
function hooks to append or prepend content to feed entries:
我们将钩住the_content
和the_excerpt_rss
函数钩子,以将内容追加或添加到提要条目中:
// Additional RSS Content
$rss_more_content = 'blah blah blah';
$rss_more_position = 'before'; // or "after"
// Function which adds content to RSS entries
function add_rss_content($content) {
global $rss_more_position, $rss_more_content;
if(is_feed()) {
if ($rss_more_position == 'before') {
$content = "$rss_more_content
\n$content";
} else {
$content .= "$rss_more_content
\n";
}
}
return $content;
}
// Add hooks
add_filter('the_content', 'add_rss_content');
add_filter('the_excerpt_rss', 'add_rss_content');
The only conditional is whether or not you want the content added at the top or bottom of the content block. This function should go into your functions.php file, but how you pull in the additional content in is up to you!
唯一的条件是您是否要在内容块的顶部或底部添加内容。 该函数应该放在您的functions.php文件中,但是如何获取其他内容则取决于您!
追加的内容如何添加点击事件