Rank Math Structured Data (dateModified)

#738082
  • Resolved ANF
    Rank Math free

    Hello Rank Math,
    I have added the following to functions.php to remove the dateModified and datePublished structured data dates

    add_filter( “rank_math/snippet/rich_snippet_article_entity”, function( $entity ) {
    unset( $entity[‘dateModified’] );
    unset( $entity[‘datePublished’] );
    return $entity;
    });

    The datePublished and dateModified are successfully removed from @type”:”WebPage”, however, they are not removed from @type”:”Article.

    Can you please confirm if additional code is required and if so, please provide this so that the dates are removed completely from the HTML source code?

    Thank you

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

    I apologize for the inconvenience you are facing with the structured data dates not being completely removed from the HTML source code.

    To ensure that the dateModified and datePublished are removed from both @type”:”WebPage” and @type”:”Article”, you can try adding the following additional filter to your functions.php file:

    add_filter( "rank_math/snippet/rich_snippet_article_entity", function( $entity ) {
      unset( $entity['dateModified'] );
      unset( $entity['datePublished'] );
      return $entity;
    });
    
    add_filter( "rank_math/snippet/rich_snippet_webpage_entity", function( $entity ) {
      unset( $entity['dateModified'] );
      unset( $entity['datePublished'] );
      return $entity;
    });

    By adding this additional filter, the dates should be removed completely from both @type”:”WebPage” and @type”:”Article” in the HTML source code.

    If you encounter any further issues or need additional assistance, please feel free to reach out. Thank you for bringing this to our attention.

    Sources:
    How to Remove Date Snippets from Search Results » Rank Math
    How to Remove Keywords Data from Article Schema » Rank Math
    Resolving Rank Math Schema Markup Related Issues
    How to Prevent Modified Date of Your Blog Posts from Being Updated » Rank Math

    ANF
    Rank Math free

    Hello,
    add_filter( “rank_math/snippet/rich_snippet_webpage_entity”, function( $entity ) {
    unset( $entity[‘dateModified’] );
    unset( $entity[‘datePublished’] );
    return $entity;
    });

    Does not remove dateModified and datePublished from @type”:”WebPage”.

    Hello,

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

    Could you please confirm if you want to remove datePublished and dateModified from the WebPage schema? If so, please try to use the following filter on your website and see if that works for you:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
        if( isset($data['WebPage']) ) {
            unset($data['WebPage']['datePublished']);
    	unset($data['WebPage']['dateModified']);
        }
    
        return $data;
    }, 99, 2);
    

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how it goes. Looking forward to helping you.

    Thank you.

    ANF
    Rank Math free

    Hello Rakibuzzaman,
    Thank you for the code.

    I would like to remove both. The above does remove both the datePublished and dateModified from the @WebPage schema.

    Hello,

    Yes, the above code we shared would remove both datePublished and dateModified from the WebPage schema.

    Let us know if you need help with anything else.

    ANF
    Rank Math free

    Hello Great,
    All resolved! Thank you.

    Hello,

    We are glad to know that this issue has been resolved. Thank you for letting us know.

    This ticket will be closed now, but you can always open a new one if you have any other questions or concerns. We are here to help you with anything related to Rank Math.

    We appreciate your patience and cooperation throughout this process.

    Thank you for choosing Rank Math.

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

The ticket ‘Rank Math Structured Data (dateModified)’ is closed to new replies.