wp_insert_post infinite loop
-
I’m trying to create a plugin in multisite network that allows me, when save a post, to save it in another blog of my choice.
[ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]
function test($post_id){ $post = get_post($post_id); $post = get_object_vars($post); unset($post[ID]); $blog_id = 4; switch_to_blog($blog_id); wp_insert_post($post, true); restore_current_blog(); } add_action( 'save_post', 'test', 1, 1 );
But this causes an infinite loop. Does anyone know where I’m wrong?
Thanks a lot
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘wp_insert_post infinite loop’ is closed to new replies.