Wordpress wp_insert_post () redirect?


Now i create a wordpress front-end post, after wp_insert_post(); i want to redirect into the full page of that post data. Here i use the this way, so it was redirect the blog index page, but i need this page redirect this post full page.

$post_insert = array( 'post_title' => $title, 'post_content' => $content, 'tags_input' => $post_tags, 'post_status' => 'publish', ); $post_id = wp_insert_post( $post_insert ); wp_redirect( site_url()."?post=$post_id" ); exit();


I think the issue is with $post_id being inside the double quotes. Try this instead:

wp_redirect( site_url()."?post=".$post_id);


It is better to use this:


The get_permalink method is the Wordpress built-in method to get a permanent link. See this url for the documentation for this method: <a href="http://codex.wordpress.org/Function_Reference/get_permalink" rel="nofollow">http://codex.wordpress.org/Function_Reference/get_permalink</a>


  • What is wrong in angularjs controller
  • Display Post with AJAX, after submitting post with AJAX
  • How to pass a PHP variable from one function to another?
  • How do I write a group_concat function in sqlalchemy?
  • Speed up insert query mysql
  • Displaying search term (Tag/Archive) in WordPress
  • Change the cart item quantity for specific products in woocommerce
  • why does .next() give me 'undefined'
  • jinja2 template not found and internal server error
  • In Akka, is ActorContext thread safe?
  • How to remove all of a jQuery UI dialog when it is closed
  • How to stamp out template in self contained custom elements with vanilla js?
  • Creating a Multi-Step Modal Using Jquery
  • Outputting SharePoint Hyperlink Column as URL
  • Form tag not showing up in haml file
  • How to explicitly/implicitly implemented interface members in C++/CLI?
  • How to pass a value from ASP.NET MVC controller to ASP.NET webforms control inside MVC View?
  • Kendo barchart category labels left and right based on value
  • Roxygen error “Skipping invalid path”
  • wxPython: displaying multiple widgets in same frame
  • OpenGL 3.3 on Mac OSX El Capitan with LWJGL
  • $wpdb not working in file of WordPress plugin
  • Meteor helpers not available in Angular template
  • MongoDB in PHP using aggregate to group by _id is null not working
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • Display issues when we change from one jquery mobile page to another in firefox
  • To display the title for the current loaction in map in iphone
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • trying to dynamically update Highchart column chart but series undefined
  • Proper way to use connect-multiparty with express.js?
  • Benchmarking RAM performance - UWP and C#
  • Load html files in TinyMce
  • Free memory of cv::Mat loaded using FileStorage API
  • Angular 2 constructor injection vs direct access
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?