WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After an WP_insert_posts array has been executed how do I then redirect the browser to that post.

Many Thanks,

share|improve this question

Try the following:

$post_id = wp_insert_post( array( 'your', 'args', 'here' ) );

$link = get_permalink( $post_id );

wp_redirect( $link );

share|improve this answer
Also need to die() right after wp_redirect(). – Rarst Feb 8 '11 at 6:26
Warning: Cannot modify header information - headers already sent by (output started at .......... Zack I think it is not working because we are not using the $post_id. we are using $the_post_id thanks to your brilliant script from a few days ago. wordpress.stackexchange.com/questions/8569/… – Robin I Knight Feb 8 '11 at 10:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.