• Resolved seanpaulfx

    (@seanpaulfx)


    Hi, I am using the WPSiteSync for Content plugin
    It copies all of my content from another page to the current website.
    I am having a problem as follows

    “datePublished”: “2020-10-10T17:17:13+00:00”,
    “dateModified”: “2020-03-04T07:35:44+00:00”,

    When I check the source code, the dateModified is still the previous date.
    Is there a way for me to remove it to look like a new post.
    I am using this filter of the WPSiteSync for Content plugin

    add_action('spectrom_sync_push_content', 'callback_function', 10, 3);
    function callback_function($target_post_id, $post_data, $response)
    {
      $time = current_time('mysql');
      wp_update_post(array(
        'ID' => $target_post_id,
    	'post_status' => 'draft',
        'post_date'     => $time,
    	'post_date_gmt' => get_gmt_from_date( $time )
      ));
    }

    Hope you understand what I write: D

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

    I thought I’d jump in here as the developer of WPSiteSync and make a comment.

    The datePublished value is stored in the post_date column in wp_posts. The dateModified is stored in the post_modified column. Your sample code is not providing a new value for post_modified, so wp_update_post() uses the old value from the database.

    I looked at the code for wp_update_post() and I think you can add two more arguments like:
    ‘post_modified’ => ‘0000-00-00 00:00:00’,
    ‘post_modified_gmt’ => ‘0000-00-00 00:00:00’
    and it should clear the modified dates, making the post appear to be new.

    I hope that helps you.

    All the best,
    The ServerPress Team

    Plugin Author Rank Math SEO

    (@rankmath)

    Hello @seanpaulfx

    Thank you for your message.

    Please ue the following filter to remove the dateModified value (though it is not recommended):

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

    The above code is if you use the Article Schema. Otherwise, you need to change the article in the rich_snippet_article_entity

    You can read more about the available filders here:
    https://rankmath.com/kb/filters-hooks-api-developer/

    Hope that helps.

    Hello @serverpress

    Thank you for helping out here. Appreciate it.

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

The topic ‘dateModified’ is closed to new replies.