Created
March 21, 2012 10:34
-
-
Save fengelz/2146067 to your computer and use it in GitHub Desktop.
Redirect to first child in 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
/*if($post has condition) { | |
redirect_first_child($post->ID); | |
}*/ | |
function redirect_first_child($post_id) { | |
$pagekids = get_pages("child_of=".$post_id."&sort_column=menu_order"); | |
if ($pagekids) { | |
$firstchild = $pagekids[0]; | |
wp_redirect(get_permalink($firstchild->ID)); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment