Article Snippet Type: datePublished, dateModified, name Errors

  • I’ve just started exploring rich snippets with Rank Math and I’ve run into a few errors. More specifically, there are 3 validation errors in the Google Structured Data Testing Tool:

      ldatePublished false (Cannot understand the value false as a date/time.)
      canceldateModifiedfalse (Cannot understand the value false as a date/time.)
      name A value for the name field is required.

    The URL in question is the following (forgive the CSS, I have just started testing everything…)

    How to Put the Bell Home Hub 1000 in Bridge Mode

    This is actually a custom post type created by a Knowledgebase plugin that we are currently using, although that may change at some point. Not sure if this is related. Any tips on what could be causing these validation errors and how to resolve them?

    Seems pretty clear that Rank Math can’t read the published date, modified date and author name, but less clear how to resolve this issue. Thanks for reading!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    Rank Math will extract the values of the datePublished and dateModified from the $_POST data when the post is published. It is likely that this data is not available in the $_POST when creating posts with the Knowledgebase plugin.
    You can however assign these values by using the following filter on your theme’s functions.php file:

    /**
     * Filter to add Brand Name for Products.
     *
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( 'rank_math/snippet/rich_snippet_article_entity', function( $entity ) {
        global $post;
        //get datePublished & dateModified from the third party plugin
        $entity['datePublished'] = $value;
        $entity['dateModified'] = $value2;
        $entity['author']['name'] = 'Name';
        return $entity;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Hi Michael,

    Thank you for the hint and code sample! We ended up retiring the KB plugin and made our own custom post type with Types. The new custom post type had the same issue so I added code as you suggested.

    Here is what we ended up adding in case it’s helpful for others in the future. This should be general enough to get the correctly formatted information from any post in WordPress:

    add_filter( 'rank_math/snippet/rich_snippet_article_entity', function( $entity ) {
        global $post;
        //get datePublished & dateModified from the third party plugin
        $entity['datePublished'] = get_post_time( 'Y-m-d\TH:i:s', false, $post, true );
        $entity['dateModified'] = get_post_modified_time( get_option( 'Y-m-d\TH:i:s' ), false, $post, true );
        $entity['author']['name'] = get_the_author_meta( 'nickname', get_the_author_meta( 'ID' ) );
        return $entity;

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/?rate=5#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘Article Snippet Type: datePublished, dateModified, name Errors’ is closed to new replies.