Search This Blog
Popular Posts
-
Elegant Themes has been developing WordPress themes for a long time. It has developed lots of popular themes including Divi, Nexus, Fa...
-
Flickr/Laura D'Alessandro See Also I took Harvard Business School's new pre-MBA course online — and it is definitely w...
-
Hello there! My blog post 'Spikes' was published on Sept. 22nd; however, the post before it called 'Flow' was published on...
-
Hi there! There isn't a true e-commerce solution here at WordPress.com. You can, however get a PayPal button. If you get a PayPal bu...
-
Good news for the secure web: WordPress will now encrypt the traffic for over a million more websites that are hosted on its servers. Wo...
-
I will publish an article only when I have something important to say. That's what I reminded myself every time the egocentric ...
-
How to start a blog or website in 5 minutes with WordPress. After publishing the post on how I started blogging full-time, I'v...
-
KOZHIKODE: E A Jabbar, a retired teacher and an activist of Malappuram based Yukthi vadi Sangham, has filed a complaint before chief minis...
-
At the ripe young age of 32, back in 2009, Uber CEO Travis Kalanick apparently launched a Wordpress blog called Swooshing, and for some ...
-
The WordPress project released today version 4.5.2 of the WordPress open-source platform that contains two security issues in two librarie...
Blog Archive
- December (18)
- November (29)
- October (27)
- September (29)
- August (31)
- July (30)
- June (29)
- May (29)
- April (30)
- March (31)
- February (28)
- January (31)
- December (31)
- November (30)
- October (31)
- September (30)
- August (43)
- July (42)
- June (33)
- May (43)
- April (36)
- March (37)
- February (31)
- January (4)
- December (1)
- November (1)
- October (24)
- September (24)
- August (25)
- July (28)
- June (18)
- September (1)
Total Pageviews
Blogroll
Quick Tip: Connect WordPress RSS Feeds to Social Networks
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.
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 FeedFirst, 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 SiteNow 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 ); endif; ?> <ul> <?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 ) : ?> <li> <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() ); ?> </a> </li> <?php endforeach; ?> <?php endif; ?> </ul>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.
ConclusionThis 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.
Source: Quick Tip: Connect WordPress RSS Feeds to Social Networks
0 comments:
Post a Comment