Problems validating schema for date time field

#703397
  • Resolved Tess
    Rank Math free

    I have tried the %date(Y-m-d)% and YYYY-MM-DD and both come up with the error: Date/time no in ISO 8601 format in field ‘datePosted’.

    What other code can I try to get this to validate? Results in the sensitive data field.

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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

    Tess
    Rank Math free

    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

    Tess
    Rank Math free

    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

    Tess
    Rank Math free

    It seems as though the %seo-title% is the main thing causing it to be invalid.

    image of invalid %seo-title% for jobPosting schema

    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.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘Problems validating schema for date time field’ is closed to new replies.