Created
December 21, 2015 08:24
-
-
Save saeidzebardast/0c99510f5be811ce2929 to your computer and use it in GitHub Desktop.
WordPress: Redirect to add new post on publish or save
This file contains hidden or 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
<?php | |
add_filter('redirect_post_location', 'redirect_to_add_new_post_on_publish_or_save'); | |
function redirect_to_add_new_post_on_publish_or_save(){ | |
if (isset($_POST['save']) || isset($_POST['publish'])) { | |
$pl = get_admin_url('', 'post-new.php'); | |
if ($pl) { | |
wp_redirect($pl); | |
} | |
} | |
} | |
function redirect_to_post_on_publish_or_save($location){ | |
if (isset($_POST['save']) || isset($_POST['publish'])) { | |
if (preg_match("/post=([0-9]*)/", $location, $match)) { | |
$pl = get_permalink($match[1]); | |
if ($pl) { | |
wp_redirect($pl); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment