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 change the case of all post titles to “Title Case”
- How to get posts published between a date and today?
- How to detect single.php (but not single-portfolio.php)?
- How to get post creation date?
- Function to execute when a post is moved to trash .
- Get current post id in functions.php
- Dynamically add id to heading tags
- Is it possible to Schedule Attachments in WordPress?
- disable WP automatically inserted line breaks after an image
- using wp_update_post on save_post
- Getting the post_id in wp_ajax function
- Fatal error: Call to undefined function post_exists()
- How to publish a post with empty title and empty content?
- delete post also attachments
- How to put last edited entry on top of the blog-post list?
- How to call function within a page/post, to dynamically generate content?
- Query posts from current year
- Restrict users from editing post based on the age of the post
- How do I use element instead of tags in WordPress post content having webP support?
- Update existing post dates to random dates
- Code to auto expire posts after 30 days
- featuring old articles without messing up with the archive
- List only child categories a post is in, of a specific parent category
- Keep a fluid max number of posts on site
- How to change post status from publish to draft using hook in wordpress?
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- Custom colors for post rows based on post meta value
- How to display an icon when a new post is published and then remove it when a specific time past?
- How to add an admin function only to posts, not pages?
- How to output comments number of a post per day?
- How to get new post URL?
- Force update all posts in custom post type, no content changes
- Custom wp_trim_words() function not trimming right
- Display custom post types by date field
- Disable REST API for a user ROLE
- How to display post tags
- How to Display Post View Count
- Remove double space after a period
- Add confirmation popup on “Move to Trash”
- 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()
- Delete Post From Front-End and attachment permanently
- Can wordpress differentiate between added and updated posts?
- Fetch posts from current week (Sunday to Saturday)
- Limit function to specific post category
- $post object is null
- When paginating a Page with the tag, how can the 2nd and subsequent page styles be customised?
- Function to show random posts from a category
- How to change the page break URL from ../post/2 to …/post/page2/
- Hiding posts in a list from specified categories
- How can I list random authors from current post category?
- How to set post expiration date and time and move the page to archive after expiration [closed]
- Disable single post page
- Enabling post thumbnails for custom post type
- Run a function when post is deleted?
- Checking is user author of number of posts?
- Create cron job without a plugin?
- Getting current post ID in functions.php
- How to rename “Publish” metabox title in post screen
- Display post from specific date
- Get random posts between specific dates / of specific age
- XML-RPC and post_date
- Action hook for new pending posts?
- Automatically republish old posts
- Uppercase first sentence in every post
- Add icon/badge next to posttitle of specific category
- Ajax posts filter by date, comments, top views, top likes
- Prepend or add an Image to the content of a Post
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Replace ‘published on date’ with ‘modified on date’ on Posts
- Why content_arr[‘extended’] removes paragraph tags?
- pre_get_posts query between 2 dates (date stored in custom post meta)
- How can I show many posts an author has per week?
- If modified on same day, show only time
- Load post attached images on a single page site with fancybox
- Exclude category from
- Setting posts_per_page for taxonomy term template
- Change post order random through out the entire WordPress
- Update all comments time to random dates?
- How to display the link (title) and thumbnail post?
- Force the “Choose from the most used tags” meta box section to always be expanded
- Show the content that is after the excerpt using child theme
- How to allow users to post only in certain category and hide elements from edit page?
- How to do set post permalinks using 6 digit random unique function?
- Can’t get buddypress notifications in front-end; why do I get this error?
- How do I display some posts fully on the homepage, and some as an excerpt only?
- Send post id through ajax and get the post content back
- WordPress Sidebar menu for posts based on date – guidance needed
- Display post x of y within category
- Force authors to Preview a post before publishing
- WordPress Automatic Filename Changer
- date issue with category post retrival
- Order posts alphabetically: how to set order=asc in mysql query?
- How to get date of post when using wp_get_recent_posts()?
- Worpdress function for difference dates