Quick Tip: Connect WordPress RSS Feeds to Social Networks

By Ian Chandler
We teamed up with SiteGround
To bring you the latest from the web and tried-and-true hosting, recommended for designers and developers. SitePoint Readers Get Up To 65% OFF Now

Displaying your social media network activity on your website can have tremendous advantages. It shows your readers that you’re an active participant in your niche and helps you establish yourself as a thought leader. The best part is that displaying your activity is fast and easy in WordPress.

WordPress Feeds

To show your social media network (SMN) activity, you’ll parse your account’s RSS feed. The SimplePie and FeedCache functionalities, which are built into WordPress, allow you to use a simple function called fetch_feed. The WordPress Codex has a handy snippet of code available for you, and in this article, we’ll go through the process of finding and parsing your feeds, step by step.

Step 1: Find Your Social Network Feed

First, you’ll have to find your SMN’s specific RSS feed. We’ll go over three popular SMNs: Facebook, Twitter, and Reddit.

For Facebook: Follow these steps, using Zapier to grab the RSS feed from any Facebook page.

For Twitter:TwitRSS.me will easily retrive the feed.

For Reddit: Reddit provides a direct link to your account’s RSS feed. Simply insert your username into this url: https://www.reddit.com/user/YourUsernameHere/.rss

Step 2: Parse Your Feed and Display It on Your Site

Now you’ll use the fetch_feed function to retrieve the RSS feed and display it wherever you choose.

Here’s the code that WordPress.org graciously provides:

<h2><?php _e( 'Recent news from Some-Other Blog:', 'my-text-domain' ); ?></h2>

<?php // Get RSS Feed(s)
include_once( ABSPATH . WPINC . '/feed.php' );

// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed( 'http://example.com/rss/feed/goes/here' );

$maxitems = 0;

if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly

    // Figure out how many total items there are, but limit it to 5. 
    $maxitems = $rss->get_item_quantity( 5 ); 

    // Build an array of all the items, starting with element 0 (first element).
    $rss_items = $rss->get_items( 0, $maxitems );


    <?php if ( $maxitems == 0 ) : ?>
        <li><?php _e( 'No items', 'my-text-domain' ); ?></li>
    <?php else : ?>
        <?php // Loop through each feed item and display each item as a hyperlink. ?>
        <?php foreach ( $rss_items as $item ) : ?>
                <a href="<?php echo esc_url( $item->get_permalink() ); ?>"
                    title="<?php printf( __( 'Posted %s', 'my-text-domain' ), $item->get_date('j F Y | g:i a') ); ?>">
                    <?php echo esc_html( $item->get_title() ); ?>
        <?php endforeach; ?>
    <?php endif; ?>

This code generates a list of 5 links, where each link leads to your recent activity. So if you just posted five threads on Reddit, this code will link to those threads.

Copy and paste this code in the sidebar.php file. Make sure to change “example.com” in the above to your RSS feed link.

Now we’ll implement the code.

For the sake of example, let’s say you want to display the feed in your sidebar. In your Dashboard, navigate to Appearance and then Editor. You’ll see a list of .php files; click on sidebar.php. Paste your code into this file and click Update File. You’ll now see your recent SMN activity in your sidebar.


This is a simple, flexible method for displaying your activity on social media networks. You can also modify the code to your liking and use it with other .php files. Even though some may call RSS out of date, it’s still a powerful method that allows you to keep your readers updated with your activity.

We teamed up with SiteGround
To bring you the latest from the web and tried-and-true hosting, recommended for designers and developers. SitePoint Readers Get Up To 65% OFF Now
  • MyBananaPie

    Great article :D
    Thanks Ian

    • Ian Chandler

      Glad you enjoyed it!

  • Insightful! For some businesses it is a must to showcase their social updates on enterprise website and adding a RSS feed section will be the best way to about this.

    I would further like to know that where is the best place to display RSS feeds on a website.

  • Great article very usefull thanks for sharing

  • Tyrohn White

    Aritcle is unique but it would have been more useful if some theoretical content was added in it. Earlier i was reading about the same subject on a blog of TemplateToaster they had both theoretical as well as technical content starting from basic to expertise programming.

  • Nice Tip
    Thanks Ian :)