Title: wp_redirect after insert post with shortcode
Last modified: August 20, 2016

---

# wp_redirect after insert post with shortcode

 *  [becskr](https://wordpress.org/support/users/becskr/)
 * (@becskr)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/wp_redirect-after-insert-post/)
 * Hi I’m having problems with wp_redirect. I know it’s because content is being
   served before the redirect, but not sure how to correct this because it’s in 
   a shortcode. Could anyone point me in the right direction?
 * [http://pastebin.com/gKL7FX78](http://pastebin.com/gKL7FX78)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Ben](https://wordpress.org/support/users/benheu/)
 * (@benheu)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/wp_redirect-after-insert-post/#post-2695055)
 * Hi Beck,
 * A server redirection using the add_shortcode function will simply never be possible,
   as you mentioned it there will be always content served before the shortcode 
   function is triggered.
    What you should do instead is a javascript redirection
   but this is not very sexy.
 * What exactly are you trying to achieve?
    Maybe there’s another solution.
 * Cheers,
    Ben
 *  [Ben](https://wordpress.org/support/users/benheu/)
 * (@benheu)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/wp_redirect-after-insert-post/#post-2695056)
 * Ok Beck,
 * If you want it to work with a JS redirection the solution will look like that.
 * [http://pastebin.com/L6xrvN8h](http://pastebin.com/L6xrvN8h)
 * Try it out and let me know how does it go.
 * Ben
 *  Thread Starter [becskr](https://wordpress.org/support/users/becskr/)
 * (@becskr)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/wp_redirect-after-insert-post/#post-2695105)
 * Thanks, after some tinkering I got it to work. Something was wrong previously
   but now it’s fine!
 *  [skapator](https://wordpress.org/support/users/skapator/)
 * (@skapator)
 * [14 years ago](https://wordpress.org/support/topic/wp_redirect-after-insert-post/#post-2695183)
 * Hi.
    I am having the same problem. Did you manage to make it work with a shortcode?
   If so could you post the solution?
 * Thanks.
 *  Thread Starter [becskr](https://wordpress.org/support/users/becskr/)
 * (@becskr)
 * [14 years ago](https://wordpress.org/support/topic/wp_redirect-after-insert-post/#post-2695185)
 * Hi there,
 * After the wp_insert post add this
 * return ‘<script type=”text/javascript”>
    <!– window.location = “[http://example.com/blahblahblah&#8221](http://example.com/blahblahblah&#8221);//–
   > </script>’;
 * The problem with this is it’s a bit clunky – it will still half load the form
   submission page and then redirect after. But that is fine for what I needed.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘wp_redirect after insert post with shortcode’ is closed to new replies.

## Tags

 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [becskr](https://wordpress.org/support/users/becskr/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/wp_redirect-after-insert-post/#post-2695185)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
