Stop boring your feedburner subscribers with static email subject lines : Make feedburner subject line dynamic

You write well thought out attention grabbing titles for your post. Unfortunately many of your email subscribers never get to see that title because it is inside an email with a boring subject line that gets repeated everyday. That pretty much sums up my frustration with feedburner emails.

Here is a simple wordpress hack that will make the subject lines of my feedburner mails dynamic. It sets the title of the latest post on your blog as the title of the feedburner email.

You need to edit 3 files in the wordpress source file for this to work

  1. feed.php
  2. feed-rss.php and
  3. feed-rss2.php

All 3 files are present in the wp-admin folder of your wordpress installation. These files are responsible for generating your rss feed. Please take a back-up of the files before proceeding with the below hack.

Edit feed.php
Locate the function get_wp_title_rss.  Replace the existing code of the function with the following

function get_wp_title_rss() {
global $post;
$myposts = get_posts(‘numberposts=1&offset=0′);
foreach($myposts as $post) :
$title = the_title();
endforeach;
 return $title;
}

Edit feed-rss.php and feed-rss2.php

Look for the line  <title> ………………………</title>  and convert it to <title><?php  wp_title_rss(); echo ” from “; bloginfo_rss(‘name’); ?></title>

That’s it. The subject line of your next feedburner email shall be title of your last post from your blogname.

Tagged as:

7 Responses to “Stop boring your feedburner subscribers with static email subject lines : Make feedburner subject line dynamic”

  1. This crashed my blog. I received the following when I went to my homepage:

    Parse error: syntax error, unexpected T_FOREACH, expecting T_STRING or T_VARIABLE or ‘$’ in /home/crankyfl/public_html/wp-includes/feed.php on line 84

  2. binaryday says:

    Can you send me your feed.php? My email address is ask@binaryday.com

  3. Yair says:

    Thanks for this hack, binaryday. Works great, with a minor variation for my WP 2.7.1: feed.php is in wp-includes, not wp-admin. I also needed to make minor fixes to your code:

    function get_wp_title_rss_old($sep = ‘»’) {
    $title = wp_title($sep, false);
    if ( is_wp_error( $title ) )
    return $title->get_error_message();
    $title = apply_filters(‘get_wp_title_rss’, $title);
    return $title;
    }

    function get_wp_title_rss($sep = ‘»’) {
    $title = get_wp_title_rss_old($sep);
    $myposts = get_posts(‘numberposts=1&offset=0?’);
    $post_title = ”;
    foreach($myposts as $post) :
    $post_title = get_the_title();
    endforeach;
    if (!empty($post_title))
    $title .= ‘ latest: ‘.$post_title;
    return $title;
    }

    Readers beware: be especially careful when copy-pasting from this post, since the ‘ character gets mixed up in encoding and are converted into some unicode character that php did not recognize as ‘. So check that it’s a simple ‘ character in your code.

    Also, I only needed to modify feed.php, since the other 2 files are already using wp_title_rss() in WP 2.7.1.

  4. gw says:

    To avoid hacking the wordpress core I wrote f.e.t.c.h. (feedburner email title and subject change hack :-) ), a little plugin basing on your code. You can download it on my page.

    http://www.gwegner.de/en/tweak-feedburners-email-subject-with-fetch-a-plugin-for-wordpress

    Thank you for your good work!

    Regards, Gunther

  5. bhagyashree says:

    hey you have a great blog!
    btw, now feedburner provides us with the option of adding the title of latest post in email subscription options.. so i didn’t have to do use any hack. :)

  6. I was excited to see this but it somehow corrupted my feed. I replaced the three php docs with the original code but it still won’t come back online. Ideas?

  7. Argh, first the code corrupted my feed and now my blog itself is down. I’m getting this: Fatal error: Call to undefined function feed_content_type() in /home7/inspird6/public_html/wp-includes/feed.php on line 8

Leave a Comment