Error in WP_update_post

The key to using WordPress outside of WordPress is include the wp-load.php file:

So your code will like:

<?php 

// Include the wp-load'
include('YOUR_WP_PATH/wp-load.php');

// Update post 1 hello word
$my_post = array(
  'ID'           => 1,
  'post_title'   => 'This is the updated post title.',
  'post_content' => 'This is the updated content.',
);

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

?>

It’s should work…

Once the wp-load.php file is included, the entire wealth of WordPress functions is provided to you. While the sample code above gets recent posts, you can do your own custom queries with WP_Query or get_posts().

Leave a Comment