How to return to a post after creating/editing it?
-
I’d like to have my site set up so that, after a user creates or updates a post, they are returned to the non-editing view of that post. I can’t quite figure out how to do this; I’d assume that
add_action
andwp_after_insert_post
are likely to be involved, but I can’t quite get there.Here is what is probably a really bad idea:
function sf_change_post_destination( $post_id, $post_after, $post_before ) { $the_url = get_home_url() . "/?p=" . $post_id; wp_redirect( $the_url ); exit; } add_action( 'wp_after_insert_post', 'sf_change_post_destination' , 10000, 3);
This *seems to* work; the idea is to use a very high priority value in the
add_action()
call so that it should be the last action to run. But, of course, the exit call (required for this to “work”) terminates the update process, and who knows what essential things are getting cancelled because of it. So, bad idea. But is there a better one? Any advice? Thanks!
- The topic ‘How to return to a post after creating/editing it?’ is closed to new replies.