WP insert post and custom taxonomy

Where is the code that catches an processes the $_POST data? Is it in a template file? Or is it in a function that is run on a hook? If it’s the latter, and if taxonomy_exists() is returning false as you suggest here (http://wordpress.stackexchange.com/questions/45798/wp-insert-post-and-custom-taxonomy#comment58402_45810), it’s possible that you’re checking before register_taxonomy has had a chance … Read more

can’t edit post_modified in wp_insert_post (bug?)

It is not bug, actually WordPress does not allow (using arguments) to set post modification date. Internally WordPress set it to current time if you are updating an existing post else just set it to post date. in /wp-includes/post.php#L3192 you can see wp_insert_post does not use this argument if ( $update || ‘0000-00-00 00:00:00’ == … Read more

Create posts on user registration

You kind of answered the question yourself already, Create a function that will create the 3 posts ex: function create_new_user_posts($user_id){ if (!$user_id>0) return; //here we know the user has been created so to create //3 posts we call wp_insert_post 3 times. // Create post object $my_bio_post = array( ‘post_title’ => ‘bio’, ‘post_content’ => ‘This is … Read more

Get post ID from wp_insert_post()

You’ll have to do this in two steps. First, you will create a post in the draft mode, using wp_insert_post(). The wp_insert_post itself will return to you the ID of the inserted post: <?php $new_post = array( ‘post_title’ => ‘Draft title’, ‘post_status’ => ‘draft’ ‘post_type’ => ‘my_custom_type’ ); $postId = wp_insert_post($new_post); ?> <form method=”post” action=”your-action.php”> … Read more

wp set object terms vs wp set post terms

Right there is no big difference between them, actually wp_set_post_terms() uses wp_set_object_terms() but does few extra check for you. That’s also noted on wp_set_object_terms() Codex page: Perhaps the wp_set_post_terms() is a more useful function, since it checks the values​​, converting taxonomies separated by commas and validating hierarchical terms in integers. http://codex.wordpress.org/Function_Reference/wp_set_object_terms#Notes