Site Mods: Altering the “more” functionality.
After writing down some of the things I wanted to achieve for the future of this blog (for my 50th post) I decided I should probably make a start on them! I'd already modified WordPress to make the "more" link (the link on the front page that says "Read more of this entry") link to the simple page URL and not to an anchor that occurs after the opening paragraph. For my next mod I thought I should continue in this vein and alter the RSS (and Atom) feeds to include the full post text, rather than an excerpt. This turned out to be ridiculously easy!
Here are the mods I did:
On line 102 of wp-includes/post-template.php, change:
$output .= ' <a href="'. get_permalink() . "#more-$id\" class=\"more-link\">$more_link_text</a>";
$output .= ' <a href="'. get_permalink() . "\" class=\"more-link\">$more_link_text</a>";
This is all that's technically necessary but if you want to clean up the code a little bit (to remove a now unnecessary tag) then do the following. On line 98 of the same file, change:
$output .= '<span id="more-'.$id.'"></span>'.$content;
$output .= $content;
Feeds took me a little longer to work out because I had to figure out what was going on in the content output functions before I realised what I had to change. Luckily, I'm about to tell you what to do so you don't need to go crawling through code like I did.
At line 3 of wp-includes/feed-rss2.php, insert the line:
So the top of the file should look like this:
header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);<br />
global $more;<br />
$more = 1;</p>
And that's all there is to it. Basically, the content output already checks to see if the global variable
$more has been set, and if it has then the entire post is output, rather than just the excerpt. As you can see, feed-rss2.php already has the variable set, it just hasb't declared it as a global variable so it won't get used in the output functions.
The same thing can be done to the wp-includes/feed-atom.php and wp-includes/feed-rdf.php files, although I'm not sure how well it would work for RDF as I don't use it.
Well, hope that was useful to you guys!