wordpress - Creating a post using PHP in one of the blogs in WP MU -


I have a PHP program to create a site / blog in a networking site. After creating the site, I want to create a post using the same PHP program.

If I use the wp_insert_post () function, then it is making posts in main site / blog, not in the new site / blog I created. I tried to call switch_to_blog () before wp_insert_post () but did not make any luck.

The following is used in the form of a plugin:

  Lt ;? Php / * Plugin Name: New Post on Site Creation * / add_action ('wpmu_new_blog', 'Default_post_so_5334372', 10, 6); Function default_post_so_5334372 ($ blog_id, $ user_id, $ domain, $ path, $ site_id, $ meta) {switch_to_blog ($ blog_id); $ My_post = array ('post_title' = & gt; 'My Post', 'Post_sign' = & gt; 'This is my post', 'Post_States' = & gt; 'Publish', 'Post_Iether' = & gt; ; 1); Wp_insert_post ($ my_post); Restore_current_blog (); }    

Comments