Remove date from Google Search Results Description

How do I remove the date from the google search results of my posts?

Is this related to WordPress or is it theme-specific?

Related posts

4 comments

  1. Paste this code in functions.php

    add_filter( 'wpseo_show_date_in_snippet_preview', false); //Returning false on this will prevent the date from showing up in the snippet preview.
    

    Note:
    WordPress SEO api

  2. I think I got it.

    Navigate to SEO>Titles and Metas and remove %%date%% from Meta description template field.

  3. Unfortunately the accepted answer is incorrect. (See 1.)

    Below is the working answer I have found. (Sourced here 2.)

    add_action('wpseo_dc_'.'DC.date.issued', '__return_false'); // Premium only
    add_filter( 'wpseo_og_article_published_time', '__return_false' );
    add_filter( 'wpseo_og_article_modified_time', '__return_false' );
    add_filter( 'wpseo_og_og_updated_time', '__return_false' );
    
    1. https://kb.yoast.com/kb/date-appears-search-results/
    2. https://gist.github.com/amboutwe/e5b83cd990b5c1bc4015c20f5e3cd754
  4. Try this, it will work

    // Remove DatePublished
     add_filter( 'wpseo_schema_graph_pieces', 'remove_datePublished_from_schema', 11, 2 );
     add_filter( 'wpseo_schema_webpage', 'remove_datePublished_property_from_webpage', 11, 1 );
    
     /**
     * Removes the DatePublished graph pieces from the schema collector.
     *
     * @param array  $pieces  The current graph pieces.
     * @param string $context The current context.
     *
     * @return array The remaining graph pieces.
     */
    function remove_datePublished_from_schema( $pieces, $context ) {
    return array_filter( $pieces, function( $piece ) {
        return ! $piece instanceof YoastWPSEOGeneratorsSchemadatePublished;
    } );
    
    }
    
    /**
     * Removes the DatePublished property from the WebPage piece.
     *
     * @param array $data The WebPage's properties.
     *
     * @return array The modified WebPage properties.
     */
    function remove_datePublished_property_from_webpage( $data ) {
    if (array_key_exists('datePublished', $data)) {
        unset($data['datePublished']);
    }
    return $data;
    
    }
    

Comments are closed.