• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Draft / WordPress REST API call to Update Post Status Fails Silently

WordPress REST API call to Update Post Status Fails Silently

Last updated on February 24, 2020 by Sal Ferrarello

Recently, I was trying to update the post status of a post from future to publish with the WordPress REST API and while the submission appeared to work, the value was not modified.

Of course, the first thing I checked was to make sure I was setting the X-WP-Nonce since I was trying to update a value (see Test WordPress REST API Endpoints from the Browser with jQuery for more information).

Finally, I realized that WordPress wouldn’t let me set the post status to publish because the post_date had not yet passed. In other words, the post was scheduled for the future so when I tried to change the status to publish, WordPress prevented this change.

I’d love to see the API response modified to return an error message when it fails like this. If anyone is looking to make an open source contribution to WordPress, I’d love this.

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Draft, Programming Tagged With: JavaScript, REST API, WordPress

Reader Interactions

Leave a Reply Cancel reply

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

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in