Tag Info

New answers tagged

0

wp_insert_post will trigger a number of hooks: save_post_{$post->post_type} save_post wp_insert_post the transition post hooks possibly edit_post and post_updated and certainly some others So, yes, there are a number of ways to trigger other functions. Use add_action or add_filter to apply a callback to the hook appropriate for your purpose.


1

Use this code snippet to use another function, function my_function( $post_id ) { //Some code } add_action( 'save_post', 'my_function' ); This fires when a post is inserted.


0

I can notice few problem without debugging - if (empty($error)) { $new_post = array( // this line is missing 'post_content' => '',/**MUST STAY BLANK!**/ // this line should not be there do_action('wp_insert_post', 'wp_insert_post'); // variable undefined $post_title | $post_parent | $success


0

Try updating your permalinks 3 times. Make sure you have set it correct. Also you should look into http://wordpress.org/plugins/super-cpt/ , makes it a lot easier to add custom post types.


1

I find the answer. After building my arguments for wp_insert_post() function and passed it to a variable $pid i set the following line after that and everything works slightly. wp_set_object_terms($pid, 'cars', 'types', true);


1

My advice is to not do long running bulk-operations over a web-connection in the first place. PHP works just fine from the command line. Write your one-time script to do whatever it is that you need it to do. If you need access to WordPress functions in that process, then include the wp-load.php file at the top of the script. Then, go to a shell prompt on ...



Top 50 recent answers are included