0

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

Many Thanks,

1 Answer 1

3

Try the following:

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

$link = get_permalink( $post_id );

wp_redirect( $link );

die();
2
  • 2
    Also need to die() right after wp_redirect().
    – Rarst
    Feb 8, 2011 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/… Feb 8, 2011 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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