Hello, I’m sorry to hear that you’re experiencing issues with validating the date/time field for your schema. It seems like you’ve tried using the %date(Y-m-d)%
and YYYY-MM-DD
formats, but they are still not validating properly.
To ensure that the date is in ISO 8601 format, you can try using the following code snippet to add the time and timezone information to the datePosted
field:
add_filter( 'rank_math/snippet/rich_snippet_jobposting_entity', function( $entity ) {
if ( empty( $entity['datePosted'] ) ) {
return $entity;
}
$entity['datePosted'] = wp_date( 'c', strtotime( $entity['datePosted'] ) );
return $entity;
} );
This filter will add the time and timezone information to the datePosted
field, ensuring that it is in ISO 8601 format. Once you’ve added this code to your theme’s functions.php
or rank-math.php
file, please retest the schema validation.
If you encounter any further issues or need additional assistance, please feel free to let us know. We’re here to help!
Sources:
Resolving Rank Math Schema Markup Related Issues
How to Change the Date & Time on Your Posts/Pages » Rank Math
How to Remove Date Snippets from Search Results » Rank Math
JobPosting Schema Type » Rank Math
Video Schema Type » Rank Math
Also, it seems to not like the %seo-title%. The title is the H1 .entry-content class.
Or is it just not validating due to the dateTime?
Thanks
Thanks. I’ve added that code to a code snippet PHP plugin.
But I’m still seeing the same errors.
Here is what I see in both Google rich results test and the PHP snippet section:
https://somup.com/c0lF0jkjed
It seems as though the %seo-title% is the main thing causing it to be invalid.
Hello,
Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.
Can you please confirm if you’re checking the schema in the Rank Math Code Validation tab? If so, please note that Rank Math sometimes needs time to parse everything in the code validation tab, making it occasionally unreliable for testing but the Schema is applied correctly in the front end when you save the post. That’s why we always suggest checking the URL directly with Rich Results Test because that is what Google actually sees.
Let us know how it goes. Looking forward to helping you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.