I’m using CMS Press for custom post types. The issue is the feed doesn’t validate because lastBuildDate is blank. I am not using WordPress’s default posts for anything and that is causing the problem.
I did a test post using WordPress’s default post and voila lastBuildDate was filled in and the feed validated.
As soon as I deleted the post it removed the date in lastBuildDate and the feed didn’t validate.
I’m using the code below to add the custom post types in the main feed but this is an issue with the feeds created by the custom post types also.
Am I missing something to get the lastBuildDate to populate?
if ( ( is_front_page() && false == $query->query_vars['suppress_filters'] ) || is_feed() ){
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( array('post_type'=>array('post', 'games', 'entertainment', 'tech', 'podcasts'),'paged'=>$paged ) );
}
I answered my own question below.
This is the solution I found based off of @Rarst’s answer. Put this in the themes functions.php and it worked like a charm!
Use WordPress functionality
The function
get_lastpostmodified()
is extensively documented. It says in the wordpress documentation that the function accepts a timezone and a post_type.Documentation
From WordPress Trac: wp-includes/post.php1
Examples:
If you want to check for the last post modified of a certain post type (let’s say ‘GAMES’). You would call the function as follows:
Following with an example of my custom feed meant for a popular job site. Here I use a Custom Post Type (CPT) called ‘JOB’:
Sources:
1 https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-includes/post.php
lastBuildDate
is getting filled with data returned byget_lastpostmodified()
function. Which only checks for nativepost
type, so if you have none – there is no date found.Filter
get_lastpostmodified
hook to return some other build date (in MySQLDATETIME
format) instead of it.