How to Update Blog content in WordPress from Web Services (API)

Hello Developers,
  If you want to update your blog content with web api then you create a new file with name update_blog.php in your api folder and paste following code :

<?php
require ("../wp-load.php");
if ($_REQUEST['id'] != "") {
global $wpdb;

$my_post = array(
 'ID'           => $_GET['id'],
                 "title"       => $_GET['title'],
 );

// Update the post into the database
 wp_update_post( $my_post );

$ar = array('reg'=>'true','msg'=>'success');
echo json_encode( $ar );
exit();
} else {
$ar = array ("reg" => 'false', "msg" => "Require Field Missing");
echo json_encode( $ar );
exit();
}
?>

You can added as many all argument of post in $my_post array and save your blog post, its required post id for update post. Now you api url is as follows :

http://www.webtecso.com/api/update_blog.php?id=

Comments