Last active
December 15, 2015 19:08
-
-
Save Melindrea/5308633 to your computer and use it in GitHub Desktop.
Unorganized (for now) elements of snippets/tools/stuff for WordPress
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
//Function for redirecting to the created post/page in WordPress to the post/page itself | |
add_filter('redirect_post_location', 'redirect_to_post_on_publish_or_save'); | |
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