0

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

Many Thanks,

3

Try the following:

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

$link = get_permalink( $post_id );

wp_redirect( $link );

die();
  • 2
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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