Call wp_update_post()
with a special value for 'post_date'
and 'post_date_gmt'
:
$time = current_time('mysql');
wp_update_post(
array (
'ID' => 123, // ID of the post to update
'post_date' => $time,
'post_date_gmt' => get_gmt_from_date( $time )
)
);
Related Posts:
- Human Time Diff, change mins to minutes
- Using system date format
- Set a post expiration and delete a post when expirate
- How to get posts published between a date and today?
- How to detect single.php (but not single-portfolio.php)?
- disable WP automatically inserted line breaks after an image
- delete post also attachments
- Query posts from current year
- Restrict users from editing post based on the age of the post
- Code to auto expire posts after 30 days
- List only child categories a post is in, of a specific parent category
- How to change post status from publish to draft using hook in wordpress?
- How to display an icon when a new post is published and then remove it when a specific time past?
- How to output comments number of a post per day?
- How to display post tags
- Allow role to delete posts but block him the wp-admin
- Why does `url_to_postid` return 0 when testing `page_for_posts` Page?
- How can I display a specific user’s first published post?
- WP_Query in functions.php overrides global $post object, even with wp_reset_query()
- Can wordpress differentiate between added and updated posts?
- Limit function to specific post category
- Function to show random posts from a category
- How can I list random authors from current post category?
- Disable single post page
- Enabling post thumbnails for custom post type
- Display post from specific date
- Action hook for new pending posts?
- Uppercase first sentence in every post
- Ajax posts filter by date, comments, top views, top likes
- Prepend or add an Image to the content of a Post
- Why content_arr[‘extended’] removes paragraph tags?
- pre_get_posts query between 2 dates (date stored in custom post meta)
- If modified on same day, show only time
- Update all comments time to random dates?
- How to display the link (title) and thumbnail post?
- How to do set post permalinks using 6 digit random unique function?
- Display post x of y within category
- WordPress Automatic Filename Changer
- Worpdress function for difference dates
- disable Tab post on nav-menus page (Admin)
- Adding bootstrap classes to video shortcodes
- Every second post different class in blog view
- Changing default WP-Site creation date
- Get post meta retrieving wrong value
- The_excerpt() doesn’t parse – how to change that?
- Add custom text automatically on each post
- What date to use as a post date? date_gmt or modified_date_gmt
- WordPress 302 Redirect to Random Product/Post/Page
- Assigning Two Different Post Dates For Single Post
- Getting Whitescreen when publishing a post [closed]
- Add code to a specific post’s content
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
- Add “Posted on” to post date
- Related Posts: Changing Function For Posts Per Page
- Optimize CPT-function with a loop
- Date is wrong on ‘all posts’ page
- Same post appears in related Posts?
- Making a wordpress page print friendly
- Help on conditional statement to accompany wp_insert_post function please?
- Set Default Post as Parent Child (Nested) Relation
- Post date automatically +100 years into the future
- I need to create “View Profile” and “Edit Profile” links by incorporating the Post Title/ID, but can’t seem to manage it
- how to show comments only author which send own posts in wordpress
- get category in list of posts // shortcode for custom related posts
- Change Old WordPress Post Date Year
- Alt text attributes not showing over portfolio images
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- Display Updated Date Instead of Published Date
- How do you update post date (year only) in a separate custom field?
- I want to change the WordPress comments file
- Replace Tag Keyword With Link Within Post Content
- Excluding tag Link from html tags in Post content
- Changing a users posts to drafts upon role change
- How to hide meta from search result only on pages?
- How do I display posts ordered by a date custom field?
- Get post id outside loop : Notice: Trying to get property of non-object
- Trim excerpt to first paragraph
- im trying make a function to auto correct posts when i open the posts in the backoffice
- How to change number of posts shown on homepage vs other pages?
- Show only top 3 posts from 3 categories in order on home page
- Skip posts, but keep posts per page
- How to display an icon when a new post is published and then remove it when a specific time past?
- How to get posts from network blog
- How to organise post by category and date
- Get post title by Alphabet
- Display metabox with date
- How to limit the number of results for all query_posts on mysite
- User driven content problems
- How can I create a menu items from meta box based on users input
- How to use wp_editor(); in functions.php then retrieve content in the template
- How *not* to show the last post on the latest posts list
- save_post not working
- wp trim function not working
- Insert Shortcode exactly at the end of the content
- display last post modified date in genesis child themes
- What function does the loop of displaying posts?
- Custom Post-Rename Function Does Not Function in WordPress 6.x
- Exclude posts by date – related post
- How to sort posts alphabetically based on a specific parent category