Codeable info

Full Feeds and the “more” Tag

Posted on by in Blog

I love the <!–more–> tag! It keeps my homepage clean, it lets me customize the text that is used to link to the full article, it encourages more pageviews, and it’s a fantastic tool to “tease” your audience. The WordPress guys really hit a home run on that one.

But it comes with a price. Unfortunately, when you use the <!–more–> tag in your posts, it doesn’t just affect the homepage. It also translates into your feeds. And since it is generally not a good thing to publish partial feeds, we want to make sure that our subscribers are getting the entire post in their feed reader.

That means that you either toss out the <!–more–> tag altogether … along with the benefits … or you could pop the hood of your WordPress installation and do a little work.

In the wp-includes directory and find the file called “post-template.php” In this file, do a quick search for the following code:

if ( preg_match(‘/<!–more(.+?)?–>/’, $content, $matches) ) {

Once you find that code, all you have to do is change that line to this:

if ( preg_match(‘/<!–more(.+?)?–>/’, $content, $matches)
&& !is_feed() ) {

Let me explain what this does. The preg_match is a line of code that searches for stuff. In this instance, it’s looking for that <!–more–>. What we want to do is exclude that line of code from being executed when publishing the feed. So, the addition of && !is_feed() means, only execute the preceding code if you are not (the ! means “not”) outputting the feed.

If you’re not comfortable making changes to your WordPress installation, there are a few plugins that are supposed to do the same thing. I’ve never used them, but try them out and see if they work.

BTW, WordPress may have remedied this already … I’m not really sure. I haven’t seen any indication of this, but they may have. Also, it should be noted that this is a feature, not a bug. Some people prefer to only publish the text before the more tag in their feeds to encourage visiting their site. I personally don’t recommend that, but it’s worth noting.

Comments Closed

Codeable info