wordpress社交系统_如何在WordPress RSS Feed中添加社交按钮

wordpress社交系统

After our article that recommended users to stop using Feedburner, many users asked us how they can get the social sharing buttons like they had on their FeedBurner feeds. While most modern feed readers include social sharing capabilities, in this article, we will show you how to add social buttons in WordPress RSS feed.

在我们的文章建议用户停止使用Feedburner之后 ,许多用户问我们如何才能像在FeedBurner供稿上一样获得社交共享按钮。 尽管大多数现代的提要阅读器都包含社交共享功能,但在本文中,我们将向您展示如何在WordPress RSS提要中添加社交按钮。

Social sharing buttons displayed in WordPress RSS Feed

First thing you need to do is download the social buttons you would want to display in your feeds. There are several social media icon sets available for free. Choose one that best suits your needs. After that you need to go to Media » Add New and upload Facebook and Twitter icons to your media library.

您需要做的第一件事就是下载您想要在Feed中显示的社交按钮。 有几种免费的社交媒体图标集。 选择最适合您的需求。 之后,您需要转到Media»Add New,然后将Facebook和Twitter图标上传到您的媒体库。

Upload social media icons to WordPress Media Library

Once you have uploaded the icons, you need to copy their location URL. Simply go to Media » Library and click on the Edit link below Twitter icon.

上传图标后,您需要复制其位置URL。 只需转到Media»Library ,然后单击Twitter图标下面的Edit链接。

Edit social icon files

On the Edit Media page, copy the File URL and paste it in a text editor. Repeat the process for the Twitter icon as well. We will need these URLs later.

在“编辑媒体”页面上,复制文件URL并将其粘贴到文本编辑器中。 也对Twitter图标重复该过程。 稍后我们将需要这些URL。

Get the icon file URL

We will use the default WordPress content filter to add these icons below each post in your WordPress RSS feed.

我们将使用默认的WordPress 内容过滤器在您的WordPress RSS feed中的每个帖子下方添加这些图标。

You need to add this code in your theme’s functions.php file or a site-specific plugin.

您需要将此代码添加到主题的functions.php文件或特定站点的插件中


// add custom feed content
function wpb_add_feed_content($content) {

// Check if a feed is requested
if(is_feed()) {

// Encoding post link for sharing
$permalink_encoded = urlencode(get_permalink());

// Getting post title for the tweet
$post_title = get_the_title(); 

// Content you want to display below each post
// This is where we will add our icons

$content .= '<p>
<a href="http://www.facebook.com/sharer/sharer.php?u=' . $permalink_encoded . '" title="Share on Facebook"><img src="Facebook icon file url goes here" title="Share on Facebook" alt="Share on Facebook" width="64px" height="64px" /></a>

<a href="http://www.twitter.com/share?&text='. $post_title . '&amp;url=' . $permalink_encoded . '" title="Share on Twitter"><img src="Facebook icon file url goes here" title="Share on Twitter" alt="Share on Twitter" width="64px" height="64px" /></a>
</p>';
}

return $content;
}

add_filter('the_excerpt_rss', 'wpb_add_feed_content');
add_filter('the_content', 'wpb_add_feed_content');

This code simply adds HTML to display social icons below post content in your WordPress RSS feeds.

这段代码只是添加HTML,以在WordPress RSS feed中的帖子内容下方显示社交图标。

We hope this article helped you add social buttons in your WordPress RSS Feeds.

我们希望本文能帮助您在WordPress RSS Feed中添加社交按钮。

If you liked this article, then please subscribe to our YouTube Channel for our WordPress video tutorials. You can also find us on Twitter and Google+.

如果您喜欢这篇文章,请订阅我们的YouTube频道以获取我们的WordPress视频教程。 您也可以在TwitterGoogle+上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-add-social-buttons-to-wordpress-rss-feed/

wordpress社交系统

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值