0

I have a unique website type that only requires 10-20 seconds to make a new post. I want my WordPress site to reload the editor page automatically after a new post has been published hence I don't need to click "Add New" button in order to load blank post editor page.

0

In no way I recommend to do that, as it will decrease the flexibility. However, if you have very rarest occasion and really need what you say, then put this code in functions.php:

add_action( 'save_post', 'newpost_redirect', 99);
function newpost_redirect() {
    if ( isset($_POST['original_publish']) && "Publish"==$_POST['original_publish']){ 
        wp_redirect(admin_url('post-new.php') , 302 ); exit;
    }
}
0

I think that using the redirect_post_location (see codex) hook would be a better way - it fires only in this particular context (when post gets redirected after being edited - see code).

add_filter('redirect_post_location', 'redirect_after_post_update', 10, 2 );
function redirect_after_post_update( $location, $post_id ) {

    // make sure we're in dashboard
    if ( ! is_admin() ) {
        return $location;
    }

    // check if post was published, not updated
    if ( ! isset( $_POST[ 'publish' ] ) ) {
        return $location;
    }

    $new_post_sceen = get_admin_url( '', 'post-new.php');

    if ( ! empty( $new_post_sceen ) ) {
        return $new_post_sceen;
    }

    return $location;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.