You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As it turns out, you're running into some undocumented behavior of wp_update_post(). Specifically, if you're publishing a post and updating its date at the same time, you need to also include --edit_date=1:
wp post update <ID> --post_date='2005-01-24T09:52:00.000Z' --post_status='publish' --edit_date=1
I don't think we should deviate from core behavior in this case. But, we can add a test case to WP-CLI to document the behavior: #428
Bug Report
Describe the current, buggy behavior
When setting a post's status to 'publish', while also setting a date, the passed date is ignored and the current date is set.
Describe how other contributors can replicate this bug
wp post create --post_title='test'
wp post update <ID> --post_date='2005-01-24T09:52:00.000Z' --post_status='publish'
wp post get <ID> --field=post_date
👉 observe the date is current dateDescribe what you expect as the correct outcome
I expect the to be able to set the post date while changing post status to 'publish'
Let us know what environment you are running this on
The text was updated successfully, but these errors were encountered: