Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PUT HTTP Request in HTTP API Wordpress

Tags:

http

wordpress

I'm unable to use put http requests in WordPress.

https://codex.wordpress.org/HTTP_API

This link says you can do it through wp_remote_request()? But where to specify that ?

Can anyone help me with this? I need a code.

like image 944
Vishal Shinde Avatar asked Sep 16 '26 03:09

Vishal Shinde


1 Answers

$body = array(
            "status" => "publish"
);
$args = array(
    'headers' => array(
    'Content-Type'   => 'application/json',
    ),
    'body'      => json_encode($body),
    'method'    => 'PUT'
);

$result =  wp_remote_request( "http:300/wp-json/wp/post/1", $args );
like image 184
Prakash Avatar answered Sep 17 '26 16:09

Prakash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!