![](https://i-blog.csdnimg.cn/blog_migrate/5fc4c99a5b04cab2bd42025f4d9b6943.png)
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 Social sharing buttons displayed in WordPress RSS Feed](https://i-blog.csdnimg.cn/blog_migrate/9d86c9371c5277ab2cdb929de69455d2.png)
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 Upload social media icons to WordPress Media Library](https://i-blog.csdnimg.cn/blog_migrate/cf3efa816f420a5a2ce44815415d8108.png)
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 Edit social icon files](https://i-blog.csdnimg.cn/blog_migrate/d0fea4e3087be0ac09200277c0e19102.png)
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 Get the icon file URL](https://i-blog.csdnimg.cn/blog_migrate/7f012e41f5abd7307955c2fcedbc0a02.png)
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 . '&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视频教程。 您也可以在Twitter和Google+上找到我们。
翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-add-social-buttons-to-wordpress-rss-feed/
wordpress社交系统