Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. if(isset($_REQUEST['vid']) ){
  2.  
  3. $id=$_REQUEST['vid'];
  4.  
  5. $post_title = 'sasa';
  6.  
  7. $post_content ='zxczxczxc';
  8.  
  9. $new_post = array(
  10. 'ID' => '',
  11. 'post_author' => $user->ID,
  12. 'post_content' => $post_content,
  13. 'post_title' => $post_title,
  14. 'post_status' => 'publish',
  15. // NOW IT'S ALREADY AN ARRAY
  16.  
  17. );
  18.  
  19. $post_id = wp_insert_post($new_post);
  20.  
  21. // This will redirect you to the newly created post
  22. $post = get_post($post_id);
  23. $url=$post->guid;
  24.  
  25. wp_redirect($post->guid);
  26.  
  27. }
  28.  
  29. //..... code as in question
  30. $post_id = wp_insert_post($new_post);
  31. $url = get_permalink( $post_id );
  32. wp_redirect($url);
  33. exit();
  34.  
  35. <?php
  36. /**
  37. * .. Template comments
  38. */
  39.  
  40. get_header();
  41.  
  42. if(...) {
  43. ...
  44. if(...) {
  45. ...
  46. wp_redirect($url);
  47. exit();
  48. }
  49. }
  50. ?>
  51.  
  52. <?php
  53. /**
  54. * .. Template comments
  55. */
  56.  
  57.  
  58. if(...) {
  59. ...
  60. if(...) {
  61. ...
  62. wp_redirect($url);
  63. exit();
  64. }
  65. }
  66. get_header();
  67. ?>
  68.  
  69. wp_redirect( get_permalink( $post_id ) );
  70. exit(); // always exit
  71.  
  72. $url = 'http://example.com';
  73. wp_redirect($url);
  74. exit();
  75.  
  76. wp_redirect(get_permalink($post->ID));
  77. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement