Custom RSS Template to Fix Pubdate

Rss Template

To jump straight to the code click here.
This post by Steck Insights Web Design is for WordPress bloggers who have subscribers that receive regular updates, but are having issues with the publishing date or time (pubdate).

To fix this problem we need to get on the same page about what RSS is, why we us it and why we need custom RSS template. Then we can move on to learning how to fix the problem through editing the pubdate through a custom RSS Template.

What is an RSS Feed?

It stands for “Rich Site Summary”. It is essentially a plain text summary of information that is updated often. For example if a blogger posts once a week their most recent blog article will be stripped down to plain text (.xml format) and condensed into a RSS feed.

Why use an RSS Feed?

The primary use for an RSS template is to access the information from websites quickly using very little space. This can be beneficial if you are trying to gather mass amounts of information from different websites or, more commonly, if you are wanting to updated, or be updated, every time a new blog post is published.

Why use a Custom RSS Template?

All of the RSS feeds are in the form of .php template files in the wp-includes folder. Because the RSS Templates are stored out side of your theme folder, every time WordPress updates any changes you have made to the files will be reverted. This can be very annoying and time consuming to go back through and redo what you have already done months or years ago. The fix to this issue is to create a custom RSS template inside of your theme folder.

Lets Get Started

Create Custom RSS Template

Create a custom RSS template by simply creating a file named feed-blog.php. Then upload it into your theme directory located at wp-content/themes/your-theme and paste in whatever code you want in your RSS Template.

RSS is on version 2.0, WordPress stores its default RSS Template at wp-includes/feed-rss2.php. You can copy all of the content from that file and past it into your new Custom RSS Template to produce the same effect WordPress uses. For you convenience I have pasted that code below.



>
	
	
	
	
	
	
	
	
	
	
		
		

		

		
		]]>
		

		

		]]>

		]]>
	
	
		]]>
	
		]]>
	


		
		


	
	
	


Register Custom RSS Template

Next you will need to register your RSS Template in wp-content/themes/your-theme/functions.php by adding the following snippet.

add_action( 'after_setup_theme', 'custom_rss_template' );

function custom_rss_template() {
	add_feed( 'blog', 'custom_rss_render' );
}
function custom_rss_render() {
	get_template_part( 'feed', 'blog' );
}

Shout out to Greg Rickaby. He has an excellent blog post on RSS Templates.

Updating Custom RSS Template Pubdate

Now that we have a custom RSS template that won’t be effected on updates, the final step is to update the pubdate so that it is relative to your time zone. You need to replace the following code that is found on line 89


With the following code.


That is all there is to it. I hope this works for you. leave any questions or comments down below.