redirect to admin page after publishing new post
-
When I click “Publish” after writing a new post, how can I make WP return to the admin page instead staying in the editor? ( with message ‘Post Published. View Post’ ) ?
in ‘/wp-admin/post.php’, they are that :
function redirect_post($post_id = '') { if ( isset($_POST['save']) || isset($_POST['publish']) ) { $status = get_post_status( $post_id ); if ( isset( $_POST['publish'] ) ) { switch ( $status ) { case 'pending': $message = 8; break; case 'future': $message = 9; break; default: $message = 6; } } else { $message = 'draft' == $status ? 10 : 1; } <strong>$location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );</strong> } elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) { $location = add_query_arg( 'message', 2, wp_get_referer() ); $location = explode('#', $location); $location = $location[0] . '#postcustom'; } elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) { $location = add_query_arg( 'message', 3, wp_get_referer() ); $location = explode('#', $location); $location = $location[0] . '#postcustom'; } elseif ( 'post-quickpress-save-cont' == $_POST['action'] ) { $location = "post.php?action=edit&post=$post_id&message=7"; } else { $location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) ); } wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) ); exit; }
If I change the bold line by :
wp_redirect( admin_url( 'edit.php' ) );
or
$location = add_query_arg( 'message', $message, 'index.php');
it works but I can’t display message… :/(idem for the last line.. it works but no message..)
How do I do this ?
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘redirect to admin page after publishing new post’ is closed to new replies.