I’ve the next web page hierarchy:
- Web page Grandparent (This web page)
- Web page Guardian 1 (Ought to direct right here)
- Web page Guardian 2
- Web page Baby
- Web page Baby
- Web page Guardian 3
- Web page Guardian 4
My dad or mum and baby pages have been assigned through web page attributes. The pages are then ordered through Look > Menus.
On the entrance finish, whenever you click on on Web page Grandparent, I might prefer it to redirect to the following menu merchandise (Web page Guardian 1).
To realize this, I’ve constructed the next web page template and utilized it to my Web page Grandparent.
<?php
/**
* Template Title: Redirect to subsequent menu merchandise
*/
if (have_posts()) {
whereas (have_posts()) {
the_post();
$pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");
$firstchild = $pagekids[0];
wp_redirect(get_permalink($firstchild->ID));
exit;
}
}
?>
For some cause, the web page is directing to Web page Guardian 2. What am I doing incorrect right here?