MoreI have been experimenting with some various options in Wordpress in order to produce a better product for all the DCoT readers out there. One of the things that I was really wanting to do was to select certain posts and only show the first few paragraphs on the front page so that readers could quickly decide if they wanted to read the entire post or just skip to the next one.

The solution to this was, on the surface, quite simple. All I needed to do was place a <!--more--> tag in the post where I wanted the post to stop on the main page. It them adds a link to the rest of the content.

Unfortunately, this did the same thing in my RSS feeds and ended up upsetting a number of the readers. As it turns out, people who read DCoT via the RSS feed read it differently than those who read it on the website. Website readers like to click around and jump from page to page. But, feed readers treat the posts more like e-mails and they don’t want to have to switch mediums in order to finish the post. This is especially true for people who access the feed content from mobile devices such as cell phones, PDAs, or smartphones.

So, I began the hunt for a solution that would allow me to keep the feeds with the full content but use the <!--more--> tag in the posts.

As it turns out, this is a relatively simple thing to accomplish within Wordpress as long as you are comfortable with editing some PHP code. I found the solution in the Wordpress forums and it requires that you edit one of your files in the Wordpress installation.

To make this solution work, you need to edit the wp-includes/post-template.php file in your Wordpress installation. In this file you will find this line:

if ( preg_match('/<!--more(.+?)?-->/', $content, $matches) ) {

In my installation of Wordpress (2.1.3), this was line 83 in the wp-includes/post-template.php file. This may be different for your installation depending upon other changes you have made to this file or your version of the file.

Once you have found this line, replace it with this line:

if ( preg_match('/<!--more(.+?)?-->/', $content, $matches) && !is_feed() ) {

Save the file and you’re done!

Now, whenever you write a post with the <!--more--> tag, the post will stop and add a link on the main page but the entire contents will be shown in the RSS feeds!

One caveat to note. Because wp-includes/post-template.php is a core file for the Wordpress plugin, it is often overwritten when upgrading to a new version of Wordpress. This means that your custom changes to this file will be undone when you upgrade. Be certain that you redo these changes each time that you upgrade. Add this to your upgrade to do list!