update post date via function

To update post date via function.php or a plugin this will work:

$time = current_time('mysql');
wp_update_post(
array (
'ID' => $post->ID, // ID of the post to update
'post_date' => $time,
'post_date_gmt' => get_gmt_from_date( $time )
)
);

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

© 2020 Jakob Helmer - Powered by WordPress - @trails&tribulations