RSS And Social Media Hacks To Customize Your WordPress Blog

Everybody is customizing their WordPress blog by learning how to use WordPress hacks and implement them in the best way possible. For this article I wanted to cover the RSS and Social Media hacks that are either very popular or useful.

RSS hacks

How to Display Feedburner count as Text

How to Display Feedburner count as Text

Displaying the Feedburner count as text is very popular these days because the Feedburner buttons are considered by some unaesthetic or just plain ugly. With this code you can easily integrate the Feed count where you desire. The following code must be put in your template, preferably in the sidebar.

//get cool feedburner count
$whaturl=" feedburner id";

//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($ch, CURLOPT_URL, $whaturl);

//Execute the fetch
$data = curl_exec($ch);

//Close the connection
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
echo $fb;
//end get cool feedburner count

Now paste the following text wherever you want to display the feed count.

 <?php echo $fb;?> 


Adding Post Thumbnail to your RSS Feeds

The thumbnail issue in RSS Feeds has always been a problem. Although you might have thought that it would work if you simply activate the option in functions.php, the solution is a little bit more complicated, as in a-dew-lines-of-code-more which you have to put in the functions.php file as well.

function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID) .
'</p>' . get_the_content();
return $content;
add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');


Inserting ads in your RSS Feed

Another interesting hack to use in your functions.php file is the one that permits you to add ads in the RSS feed. The following code will add a link ad before the content. You can customize it and use an image instead of link, or by placing the ad after the content.

function insertRss($content) {
        $content = 'text before content'.$content.'<hr /><a href="">Design your way - example of a feed ad</a><hr />';
    return $content;
add_filter('the_content', 'insertRss');


Control when the posts are available via RSS

Control when the posts are available via RSS

This hack is useful so that the post will not be immediately sent to your subscribers and give you the time to edit it in case you have an error. Again using the functions.php file, we’re going to add the following code and edit it to please your needs.

function publish_later_on_feed($where) {
global $wpdb;

if ( is_feed() ) {
// timestamp in WP-format
$now = gmdate('Y-m-d H:i:s');

// value for wait; device
$wait = '10'; // integer


// add SQL-sytax to default $where
$where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
return $where;

add_filter('posts_where', 'publish_later_on_feed');


Redirect WordPress Feeds to Feedburner via .htaccess

One way of doing this is by using the FD Feedburner plugin but if you want to reduce your server’s load you can modify the .htacces file by adding the following lines:

# temp redirect wordpress content feeds to feedburner
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
 RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
 RewriteRule ^feed/?([_0-9a-z-]+)?/?$ [R=302,NC,L]

# temp redirect wordpress comment feeds to feedburner
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
 RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
 RewriteRule ^comments/feed/?([_0-9a-z-]+)?/?$ [R=302,NC,L]


Change Your WordPress Feed Links without .htaccess

Of course, there’s an alternative to almost everything and the previous hack is not an exception. You can change the WordPress feed links by editing the functions.php file and inserting the following code:

function custom_feed_link($output, $feed) {

$feed_url = '';

$feed_array = array('rss' => $feed_url, 'rss2' => $feed_url, 'atom' => $feed_url, 'rdf' => $feed_url, 'comments_rss2' => '');
$feed_array[$feed] = $feed_url;
$output = $feed_array[$feed];

return $output;

function other_feed_links($link) {

$link = '';
return $link;

//Add our functions to the specific filters
add_filter('feed_link','custom_feed_link', 1, 2);
add_filter('category_feed_link', 'other_feed_links');
add_filter('author_feed_link', 'other_feed_links');


Disable WordPress Feed

You probably heard of the modifications to the wp-settings.php core file that can disable the feeds. Well. Don’t. The only safe solution is by editing the functions.php file by adding these lines:

 * disable feed
function fb_disable_feed() {
	wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );

add_action('do_feed', 'fb_disable_feed', 1);
add_action('do_feed_rdf', 'fb_disable_feed', 1);
add_action('do_feed_rss', 'fb_disable_feed', 1);
add_action('do_feed_rss2', 'fb_disable_feed', 1);
add_action('do_feed_atom', 'fb_disable_feed', 1);


Social Media hacks

Display Twitter followers count as text

Display Twitter followers count as text

This feature is as common as showing the Feedburner count as text and it has been done by a lot of programmers. Of course, as many other hacks, to implement this you have to edit the functions.php file.

function rarst_twitter_user( $username, $field, $display = false ) {
	$interval = 3600;
	$cache = get_option('rarst_twitter_user');
	$url = ''.urlencode($username);

	if ( false == $cache )
		$cache = array();

	// if first time request add placeholder and force update
	if ( !isset( $cache[$username][$field] ) ) {
		$cache[$username][$field] = NULL;
		$cache[$username]['lastcheck'] = 0;

	// if outdated
	if( $cache[$username]['lastcheck'] < (time()-$interval) ) {

		// holds decoded JSON data in memory
		static $memorycache;

		if ( isset($memorycache[$username]) ) {
			$data = $memorycache[$username];
		else {
			$result = wp_remote_retrieve_body(wp_remote_request($url));
			$data = json_decode( $result );
			if ( is_object($data) )
				$memorycache[$username] = $data;

		if ( is_object($data) ) {
			// update all fields, known to be requested
			foreach ($cache[$username] as $key => $value)
				if( isset($data->$key) )
					$cache[$username][$key] = $data->$key;

			$cache[$username]['lastcheck'] = time();
		else {
			$cache[$username]['lastcheck'] = time()+60;

		update_option( 'rarst_twitter_user', $cache );

	if ( false != $display )
		echo $cache[$username][$field];
	return $cache[$username][$field];

Usage example:

echo rarst_twitter_user('boogiesbc', 'name').' has '.
rarst_twitter_user('boogiesbc', 'followers_count').' followers after '.
rarst_twitter_user('boogiesbc', 'statuses_count').' updates.';


Add Twitter’s official tweet badge

Add Twitter's official tweet badge

This code works the same way as the one offered by TweetMeme, the difference between them consists in the fact that this one is developed by Twitter and it has the recommended following option. The code can be entered anywhere in the loop.

<script src="" type="text/javascript"></script>
   <a href="" class="twitter-share-button"
      data-url="<?php the_permalink(); ?>"
      data-text="<?php the_title(); ?>"
      data-related="boogiesbc:Owner of Design your way"


Add Facebook Like Button in WordPress

Add Facebook Like Button in WordPress

Having an article that goes viral is very important for your site, making it popular and delivering your content to a lot of people and Facebook gives you the opportunity to get this exposure through the like button. For example, an article of mine, 38 New PS Tuts For You Photoshoppers, has in this moment 1,259 likes on Facebook, which is a lot and because Twitter and Facebook work like domino pieces it also got 1058 Retweets. Since then I received 41.000 visits on the article. Yeah, now you surely want to add the “Like” button on your site.

Paste the code inside the loop. The most used location for it is in the single.php file.

<iframe src="<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:60px;"></iframe>

Add the new Digg buttons to WordPress

Add the new Digg buttons to WordPress

Normally, you can do this with a plugin but most plugins place the button in a rigid position, whereas with these codes you can put the badges wherever you desire in the Wp Loop.

The normal size button:

<a class="DiggThisButton DiggMedium" href="<?php the_permalink() ?>&title=<?php the_title(); ?>&bodytext=<?php the_excerpt(); ?>"</a>  
<script src="" type="text/javascript"></script>  

More info

The small button:

<a class="DiggThisButton DiggCompact" href="<?php the_permalink() ?>&title=<?php the_title(); ?>&bodytext=<?php the_excerpt(); ?>"</a>  
<script src="" type="text/javascript"></script>  

Add Facebook share buttons to WordPress

There are two share buttons, the huge one, which you can see in the left side of this page and the compact one. The same as the Digg badges, you can put these where you want in your WordPress blog.

Compact version:

<a name="fb_share" type="button_count" href="">Share</a><script src="" type="text/javascript"></script>

Big version:

<a name="fb_share" type="box_count" href="">Share</a><script src="" type="text/javascript"></script>

Add to delicious button with count display

Add to delicious button with count display

I wanted to offer you a hack for this one but I just fell in love with the plugin offered by Deepu Balaban plugin.

As he says it, it is a cool delicious bookmarking button/badge with total bookmark count. It adds a delicious badge or button to your post or page which allows you to bookmark the post. It also reflect a real-time count of how many times your page has been bookmarked in delicious, just like tweetmeme button does for twitter. Both standard and compact version of the badge to choose from.

After installing the plugin, make sure that you put the required codes to display the badge.

Compact version

<?php delit_compact(); ?>

Normal version

<?php delit_normal(); ?>

Variations of this solution can be found on

Thank you for reading this article. If you want to receive more articles like this one subscribe to the RSS Feed or follow me on Twitter.

Enjoyed this article? Subscribe to read more like it