2

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

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

2
  • I didnt understand. You have some date in your meta description and you want to remove that data from dascription? Can you be more precise? Do you use any SEO plugin?
    – pendjer
    Commented Dec 4, 2013 at 19:42
  • I use Wordpress Yoast plugin - for some reason the date of the post is the first thing that appears on the google meta description - i don't know how this is added to the description
    – JoaMika
    Commented Dec 4, 2013 at 19:55

4 Answers 4

2

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

0

I think I got it.

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

0

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
0

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 \Yoast\WP\SEO\Generators\Schema\datePublished;
} );

}

/**
 * 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;

}
2
  • Try to add an explanation as to WHY your answer works and how. Commented Sep 27, 2022 at 20:50
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 27, 2022 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.