help me to remove datePublished

#5744
  • Resolved Gopi
    Rank Math free

    need to remove date / json ld

    ,”datePublished”:”2019-05-20T18:45:45+00:00″,”dateModified”:”2019-05-21T18:10:23+00:00″

    Do you have any setting to stop displaying those values

    please help me Thanks in advance

    • This topic was modified 4 years, 11 months ago by Gopi.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Gopi
    Rank Math free

    seo-by-rank-math/includes/modules/rich-snippet/snippets/class-author.php
    seo-by-rank-math/includes/modules/rich-snippet/snippets/class-article.php
    seo-by-rank-math/includes/modules/rich-snippet/class-jsonld.php

    Todd
    Rank Math free

    Hello Gopi,

    Thank you for getting in touch.

    You can use this filter in your theme’s functions.php file to remove certain OpenGraph tags:

    https://rankmath.com/kb/filters-hooks-api-developer/#remove-opengraph-tags

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Gopi
    Rank Math free

    Thanks for your reply i have added the piece of code

    add_action( ‘rank_math/head’, function() {
    global $wp_filter;
    if ( isset( $wp_filter[“rank_math/json_ld”] ) ) {
    unset( $wp_filter[“rank_math/json_ld”] );
    }
    });

    let me check how it works

    HI there,

    Thanks for the follow up.

    If you intend to remove all the json_ld data from your posts then this code should be able to work perfectly.

    Let us know how this goes. Thank you.

    Gopi
    Rank Math free

    i want to remove only date, then what change do i need to make.

    Please hellp

    thanks in advance

    Hello,

    To disable the datePublished property in the Schema.org data for your articles, you can use the following code:

    add_filter( 'rank_math/snippet/rich_snippet_article_entity', function( $data ) {
    	unset( $data['datePublished'] );
    	return $data;
    }, 10, 1 );

    Hope that helps.

    Gopi
    Rank Math free

    Thanks its working fine

    Hi there,

    Thanks for the follow up.

    I am glad that this is now resolved 🙂

    Feel free to contact us should any other issues come up.

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

The ticket ‘help me to remove datePublished’ is closed to new replies.