[wp-trac] [WordPress Trac] #55129: WP REST API - Updating "status" field on a "post" from "future" to "publish" does not work

WordPress Trac noreply at wordpress.org
Thu Feb 10 18:12:15 UTC 2022


#55129: WP REST API - Updating "status" field on a "post" from "future" to
"publish" does not work
--------------------------+------------------------------
 Reporter:  mcmwebsol     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  REST API      |     Version:  5.9
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by rafiahmedd):

 You can follow this one:-

 {{{#!php
 <?php
 $api_response = wp_remote_post( 'https://WEBSITE/wp-
 json/wp/v2/posts/{POST_ID}/', array(
         'headers' => array(
                 'Authorization' => 'Basic ' . base64_encode(
 'LOGIN:PASSWORD' )
         ),
         'body' => array(
                 'status' => 'publish'
         )
 ) );


 if( wp_remote_retrieve_response_message( $api_response ) === 'OK' ) {
         echo 'The post has been updated successfully';
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55129#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list