Wordpress Tutorial Add Social Buttons in RSS Feed

WordPress Tutorial Add Social Buttons in RSS Feed

Adding social buttons to wordpress RSS feed is always good for SEO and it will increase your website visibility to other users. we have steps for adding social buttons to RSS feed.

How to Add Social Buttons in RSS Feed

Wordpress Tutorial Add Social Buttons in RSS Feed
WordPress Tutorial Add Social Buttons in RSS Feed

 

Why social share buttons are important in RSS feed.

RSS feed is super great feature for publishing news to multiple search engine and news site. Through RSS feed your website will viewable to many of people. You may be seen already, some of popular news and bigger websites are showing share buttons in RSS feed. So through RSS feed you can share your articles to social media sites.

 

Using following simple code snippet you can add RSS feed share buttons to wordpress RSS feed.

// add custom feed content
function wpapi_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="http://images.purabtech.in/twitter-32x32.png" 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="http://images.purabtech.in/facebook-32x32.png" title="Share on Twitter" alt="Share on Twitter" width="64px" height="64px" /></a>
</p>';
}

return $content;
}

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

I Downloaded free share icons from following URL:
http://www.blogperfume.com/new-27-circular-social-media-icons-in-3-sizes/

Here in this example code we used facebook and twitter share buttons which are most popular social sites in the world.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.