Created
May 29, 2014 06:52
-
-
Save 0v3rth3d4wn/2ccc778b07032301a6f9 to your computer and use it in GitHub Desktop.
Save and add new post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Publish and go to add new post or CPT | |
* @param int $post_id The Post id | |
* @return void | |
*/ | |
function save_and_new( $post_id ) { | |
$cpt = ( $_POST['post_type'] !== 'post') ? $_POST['post_type'] : false; | |
if ( isset( $_POST['publish'] ) || isset( $_POST['save'] ) ) { | |
if($cpt) { | |
wp_redirect( admin_url( 'post-new.php?post_type=' . $cpt ) ); | |
exit; | |
} else { | |
wp_redirect( admin_url( 'post-new.php' ) ); | |
exit; | |
} | |
} | |
} | |
add_action( 'save_post', 'save_and_new' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment