There was a time, not too long ago, when blogging was only about creating full-length entry content for readers to peruse and interact with. That time has long passed, however, and has given way to the era of tweets, blogrolls and link lists, micro-entries, digests, and all kinds of other content which gets published right alongside traditional content.
When it’s placed into a regular WordPress blog design, there’s actually nothing wrong with all of that additional content. It makes semantic sense in terms of its placement, the way its shown, when it is shown, and how users highlight it. However, each of the things listed above is technically a WordPress post. And every post is placed into the same broad, general RSS feed for syndication to a website’s audience via web browsers, mobile devices, and feed readers.
It’s easy to see why this might cause some problems. With so much content, users will find it hard to focus on just one aspect of the website and they may become confused about the site’s mission or expertise. When full-length articles are placed next to tweets, which are themselves placed right below a list of recommended links, it becomes harder to see the blog as a content destination and more likely to view it as some sort of personal social network. That’s likely to send readers to other, competing websites — the makings of a real crisis in traffic, search engine rankings, and overall respect for any website online.
Overcoming the Overload of Content: How it’s Done
In recent years, WordPress developers have begun deploying new types of RSS feeds to separate their many types of content into separate, contextual feeds that give users only the content they wish to read. This spares them the confusion of digging through status updates to view a typical WordPress post, and it keeps things like feed readers and mobile devices free of intrusive, low-character writings which have little or no relevance to a website’s subject matter.
This is done by using conditional variables within a traditional WordPress RSS feed setup and it involves creating both a new PHP template file and a new WordPress page itself. The process is relatively easy, as it uses existing WordPress syndication code with minor modifications, and it’s the number one way to retain high traffic and solid levels of respect among a diverse readership. Here is how a typical RSS feed becomes a specialized source of full-length article syndication.
First, Copy the Existing WordPress RSS 2.0 Feed into a New Template
This trick actually doesn’t modify the structure of the WordPress RSS Feed at all, making it easy for users to simply duplicate the existing RSS 2.0 feed template’s PHP and XML code into a new document and make minor changes to the top of the file in order to only display certain groups of entries. Of course, more experienced developers might want to take this opportunity to craft an entirely new feed with new display properties but, for the vasty majority of WordPress users, the existing feed structure can be left untouched.
For those new to modification of the existing RSS feeds, it’s worth noting that WordPress includes three different types of feeds (and thus templates) with every installation. Each of these feed templates can be found in a theme’s root directory, located at the following path:
Within this directory, look for three distinct template files which all begin with the “feed” prefix. Those files are:
For the purposes of this tutorial, the “
feed-rss2.php” file is the one which will essentially be duplicated in order to create a new RSS feed which shows only full articles to the reader. Open this file, copy the entirety of its contents, and paste that information into a new plain text file using a typical text editing application. Save the file as “
feed-main-content.php.” Upload that file to the same theme WordPress directory where the original WordPress feed files are located; next, some minor edits will be made to that file.
Open the “
feed-main-content.php” file directly on the WordPress installation’s server. At the top of this file, a new header will be inserted that identifies the template in the WordPress Dashboard and establishes limits for the type and amount of content which can be included with this feed.
Tell WordPress Where to Locate the File, and Tell the File Which Content to Locate
The neat thing about the WordPress RSS feeds is that they can all be controlled by customizing a few variables at the top of the file, before the actual content routine begins and the fields are populated. For our purposes here, we will customize the number of entries which can be contained in the feed, as well as the categories from which the RSS feed can pull content. That will help exclude things like tweets, digest posts, links, and other information that isn’t relevant to readers who use an RSS reader application. Here’s what the top of the file will now look like:
/* Template Name: Feed of Site's Main Content */ $numposts = 15; $posts = query_posts('showposts='.$numposts.'&cat=4,8,10,13,11,19,26'); $more = 1;
There are three important variables to be defined in this setup. The first is the “
$numposts” variable which controls how many entries are actually displayed in the feed itself. This is much like controlling how many posts are published to a website’s index page, and it should be set somewhere between 10 and 25, depending on a site’s frequency of updates and how far back it wishes to display entries to users.
The second and perhaps most important variable is “
$posts.” Normally, this variable is defined broadly and allows the RSS feed to include any and all content published within the WordPress Dashboard. Since that is what we are specifically trying to eliminate, the variable has instead been turned into a database query. This query looks for category ID numbers within the WordPress database and then includes articles in the feed which are published in those categories. All entires published to unlisted categories are excluded from the feed, thus turning it into a source of the site’s regular content instead of a general feed that prints everything an author or a plugin files into the database.
Finally, the “
$more” variable controls whether or not the full entry is included in the feed. If this is set to zero, WordPress will produce an RSS feed full of summaries and users will be required to click through to the article for the full story. When set to 1, it includes the full entry text into the RSS feed, thus allowing a reader to stay within the confines of their RSS reader application when catching up on a site’s latest posts. This is the ideal setting for a “main content” feed, as it is designed to eliminate extra clicks and content from inconveniencing syndicated readers.
When this information has been pasted into the top of the file, it’s safe to save and upload the modified PHP template. Be sure to include the commented header information that contains the template name, as this ensures that it will be seen by the Dashboard during the second step of the process when a custom page is created based on this new template file.
Creating a Custom Page to Make the New Feed Accessible to the Masses
Now that the actual PHP template file has been produced and the special, article-only RSS feed has been established, it’s time to create a custom WordPress page which will allow this new feed to be accessed using a “friendly” permalink. This is done simply by creating a new page in the Dashboard and assigning it a default template, rather than filling in the “body” text area with page content.
Start by logging into the WordPress Dashboard and clicking the “Pages” category on the sidebar. From there, click “Add Page” or “Add New,” and wait for the resulting control panel page to load. As mentioned earlier, the actual body text of the page will be left blank, as its content will be pulled directly from a template. In this dialog, only the page title needs to be filed out. This page title will actually do nothing more than to generate the page’s permalink, so name it something user-friendly which can be easily read and remembered. A great example is “Main Feed” or “Main Content.” The resulting URL to the site’s new feed would appear like the following:
This is the same way a regular page would appear, which means users won’t have difficulty accessing the new, more robust source of the site’s usual content. Now, in the sidebar area, locate the “Page Attributes” box. The setting to be modified here is the “Default Template” drop-down menu. In it, a list of custom-created templates will appear, so long as those custom templates have been given Dashboard-friendly names so that the control panel can “see” them.
If you’ve done everything right up to this point, a template named “Feed of Site’s Main Content” will appear in the list. Select that template and then save all changes made to the new page. This is essentially the end of the road when it comes to creating a feed full of the site’s richest articles.
Be sure to point your browser toward the new feed’s permalink and ensure that everything displays as it should. Remember that WordPress variables and RSS feed code can be a bit picky, and this might result in a few errors that can be easily fixed. If everything works, then it’s time to place links to the new feed on the website itself and in the “
header.php” template, where the new RSS feed can be linked to via a meta tag which allows browsers to self-discover this source of syndicated content.
When everything has been linked to updated, the process is complete and users will now be able to enjoy rich website content without all of the “fluff” that often parallels it on the typical, 21st century blog.
- How to Parse RSS Feeds as Content in WordPress
- How a Custom WordPress Plugin Can Help You Manage a Website
- Tips for Maintaining a Legacy WordPress Website
- Create a Local WordPress Development Environment for Free with DevKinsta Sponsored
- How to Add SSL to Your WordPress Website
- An Early Look at Full Site Editing in WordPress
- The Challenge of Switching from a Page Builder to the WordPress Gutenberg Block Editor
- How to Display Content Based on WordPress User Roles