Unable to remove datePublished from rank-math-schema

#629096
  • Resolved Anonymous
    Rank Math free

    We want to remove only datePublished from all places (posts and pages) including this schema script “application/ld+json” class=”rank-math-schema”. We are using the below code but it’s not removing “datePublished” from rank-math-schema. Let us know how to fix this.

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

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

    add_filter( 'rank_math/opengraph/facebook/article_published_time', '__return_false');

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

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

    The first filter you’ve shared is not correct. Please try to replace that with the following one and see if that works for you:

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

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

    Once done, please try to clear your website cache and check again. If the issue still persists, then you can share your website URL with us so that we can check the issue further for you.

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

    Thank you.

    Anonymous
    Rank Math free

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Anonymous
    Rank Math free

    I have updated the first filter but I suppose it’s not the folder for the issue I reported.
    I am still seeing the datePublished field under the json schema.
    See screenshot here: https://ibb.co/6wt4qLK
    I want to remove this datePublished from “application/ld+json” class=”rank-math-schema” schema line.
    I think Json filter is for that but that is not working.

    I shared URL for sample page in sensitive data field. Please check.

    Hello,

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    Looking forward to helping you.

    Thank 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 4 replies - 1 through 4 (of 4 total)

The ticket ‘Unable to remove datePublished from rank-math-schema’ is closed to new replies.