• Resolved pedroreis

    (@pedroreis)


    Hello,

    I need to remove datePublished and dateModified from Schema in order to Google not show dates in certains posts.

    I tried to use the following code in functions.php, but it is not working (in this case i need to apply in the single posts with ID 531 and 141):

    —————————————————————————————————

    function vanv_remove_published_modified_dates( $graph_piece ) {
    if ( is_single ( [ 531, 141 ] ) ) {
    unset( $graph_piece[‘datePublished’], $graph_piece[‘dateModified’] );
    return $graph_piece;
    }
    }
    add_filter( ‘wpseo_schema_article’, ‘vanv_remove_published_modified_dates’ );

    add_filter( ‘wpseo_schema_webpage’, ‘vanv_remove_published_modified_dates’ );

    add_filter(
        ‘wpseo_frontend_presenter_classes’
        , function($filter) 
        {
            return array_diff($filter, [
                ‘Yoast\WP\SEO\Presenters\Open_Graph\Article_Published_Time_Presenter’,
                ‘Yoast\WP\SEO\Presenters\Open_Graph\Article_Modified_Time_Presenter’,
            ]);
        }
    );

    —————————————————————————————————

    I am doing anything wrong? Can you please help?

    Thank you.

Viewing 1 replies (of 1 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello @pedroreis

    Thanks for following up on your request. To reiterate, our plugin outputs?datePublished?and?dateModified?schema.org structured data, so there’s no feature in our plugin to disable that and the plugin pulls the values in your WordPress dashboard when a post is published or modified respectively. Sadly, we are unable to review your code implementation. Please speak with a web developer.

Viewing 1 replies (of 1 total)
  • The topic ‘Hide from the Schema datePublished and dateModified only in certain posts’ is closed to new replies.