追加的内容如何添加点击事件_追加和添加到WordPress RSS Feed内容

追加的内容如何添加点击事件

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_contentthe_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文件中,但是如何获取其他内容则取决于您!

翻译自: https://davidwalsh.name/wordpress-rss-feed-content

追加的内容如何添加点击事件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值