Title: rajrin's Replies | WordPress.org

---

# rajrin

  [  ](https://wordpress.org/support/users/rajrin/)

 *   [Profile](https://wordpress.org/support/users/rajrin/)
 *   [Topics Started](https://wordpress.org/support/users/rajrin/topics/)
 *   [Replies Created](https://wordpress.org/support/users/rajrin/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/rajrin/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/rajrin/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/rajrin/engagements/)
 *   [Favorites](https://wordpress.org/support/users/rajrin/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Create new posts directly in database](https://wordpress.org/support/topic/create-new-posts-directly-in-database/)
 *  [rajrin](https://wordpress.org/support/users/rajrin/)
 * (@rajrin)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/create-new-posts-directly-in-database/#post-718254)
 * Why not use wp_insert_post( ) ?
 * [http://codex.wordpress.org/Function_Reference/wp_insert_post](http://codex.wordpress.org/Function_Reference/wp_insert_post)
 * RS
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Category update – is failing](https://wordpress.org/support/topic/category-update-is-failing/)
 *  Thread Starter [rajrin](https://wordpress.org/support/users/rajrin/)
 * (@rajrin)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/category-update-is-failing/#post-760530)
 * OK _ Problem solved
    Instead of separately updating the category I am using the
   wp_update_post function…and it works.
 *  require ‘wp-blog-header.php’;
 *  $post_author = $_POST[‘post_author’];
    $cats = array(); $x = $_POST[‘cat’];
 *  if ($x){
    foreach ($x as $t){ //echo $t;
 *  array_push($cats,$t);
    } }
 *  $post_category = $cats;
    $post_datar = compact(‘ID’, ‘post_author’, ‘post_date’,‘
   post_date_gmt’, ‘post_content’, ‘post_title’, ‘post_category’, ‘post_status’,‘
   post_excerpt’, ‘post_name’); wp_update_post($post_datar);

Viewing 2 replies - 1 through 2 (of 2 total)