Redirect WordPress feed to Feedburner

Ideally you want it all to just magically work. You want people visiting your WordPress feed URL to get pushed onto your Feedburner URL, but still allow Feedburner to grab your new posts. All without setting up specific URLs for it all. Let’s set up a little redirect magic.


add_action( 'template_redirect', 'tcb_rss_feedburner_redirect' );
function tcb_rss_feedburner_redirect() {
  global $feed;

  // Confgirable settings.
  $REDIRECT_COMMENTS = false;
  $feedburner_url    = 'http://feeds.feedburner.com/tcbarrett';

  // Have we matched redirect criteria?
  $do_redirect = false;

  // Only redirect if a feed list is being requested.
  if( is_feed() && !is_single() ) :
    // Allow feedburner user agent...
    if( preg_match( '/feedburner/i', $_SERVER['HTTP_USER_AGENT'] ) )
      return;

    // Optionally redirect comments too (uncommon)
    if( preg_match( '/comments/', $feed ) ) :
      $do_redirect = $REDIRECT_COMMENTS;
    else :
      $do_redirect = true;
    endif;

    if( $do_redirect ) :
      wp_redirect( $feedburner_url, 302 );
      exit();
    endif;
  endif;
}

Adding your public Google+ posts to WordPress

This is amazingly simple!

Well, I say that, there is a small warning that comes with this. There is no official RSS feed for Google Plus. Any feeds made available cannot be relied on to last forever, either due to the third-party losing interest or money, or because Google release their own.

The first Google Plus Feed

The first Google Plus RSS feed on AppSpot
The first Google Plus RSS feed on AppSpot

Just back in July ghacks.net blogged on this very topic. They suggested using plusfeed on AppSpot. As you can see, that has now closed.

The second Google Plus feed
However, some enterprising people have created plusfeed2. It really as simple as grabbing your Google Plus ID and appending it to the plusfeed2 url and putting it in an RSS widget. Just like any other blog.

Your Google Plus posts in you page content
If you don’t want to be restricted to your widgetized sidebars, you can insert your Google Plus posts directly into your posts using a shortcode:

[[rssfeed feed="http://plusfeed2.appspot.com/104120819592562195182"]]

[rssfeed feed=”http://plusfeed2.appspot.com/104120819592562195182″]

NOTE: This way of adding Google+ posts relies on a third-party RSS feed, so it extends the embedding RSS feeds into your post content idea. Please make sure you have that short code working before trying it out. Alternatively, if you just want your Google+ posts in a sidebar widget, then you can use it normally.

Embed RSS feed into your WordPress page content

RSS feeds are common in sidebars. Fuelled by widgets and looking much the same from site to site. Some designers create widgetized areas for their clients so they can put RSS feeds in the main content column. There is a simpler way, using a handy shortcode.

RSS Feed shortcode

function tcb_rssfeed_shortcode($atts){
  include_once(ABSPATH.WPINC.'/rss.php');
  $default = array(
    'feed'    => 'http://www.tcbarrett.com/feed',
    'entries' => 3,
  );
  extract( shortcode_atts($default, $atts) );
  if( function_exists('wp_rss') )
     return wp_rss($feed, $entries);
  return '';
}
add_shortcode('rssfeed', 'tcb_rssfeed_shortcode');

You can now easily insert your own feed:

[[rssfeed]]

Here is an example of my own site’s rss feed:

[rssfeed]

How to extend the idea

There are various ways one could expand on this. For example, adding optional pre and post text would allow a wrapping div and title to be added.