• hello sir, i have a new website that update data on some interval and its also have google news approval but when i update post then its not change post first publish date because google news only work on post first publish date not on updated date
    please give me a code so when i click on update then its change posts first publish date with last modified

    my question is not (“how to show last modified date on post”)
    but exact question is “how to change post publish date with modified in database”

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there,

    the theme has no control over this, thats a core WP function, and we do not have a snippet for that.

    You would need to ask in the general forums or look for an answer on site like the wordpress stack exchange.

    Thread Starter zestpush

    (@dhaka11021)

    ok i got it

    `function my_function( $post_id ) {
    $postdate = date( ‘Y-m-d H:i:s’, strtotime( current_time( ‘mysql’ ) ) );
    $my_args = array(
    ‘ID’ => $post_id,
    ‘post_date’ => $postdate );
    if ( ! wp_is_post_revision( $post_id ) ){
    remove_action(‘save_post’, ‘my_function’);
    wp_update_post( $my_args );
    add_action(‘save_post’, ‘my_function’); } }
    add_action(‘save_post’, ‘my_function’);

    Glad to hear that – and thanks for sharing

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to change post first publish date with modified date’ is closed to new replies.