How to update post publish date time on click wordpress

so i need to make button or link which will update post publish date.

i found this but i dont know how to call it.

$time = current_time('mysql');

wp_update_post(
    array (
        'ID'            => $id,
        'post_date'     => $time,
        'post_date_gmt' => get_gmt_from_date( $time )
    )
);

Read more here: How to update post publish date time on click wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *