Redirect to first child
-
Hi,
I’ve found this template code in another topic, here.
It is perfect for what I want to do.
My only problem is that it applies only to 2nd level children.
I would love to have it redirect to 3rd and 4th also.Parent > Redirects to… (OK, works)
– children 2nd > redirects to… (not OK)
– children 3rd > redirects to… (not OK)
– children 4thI have no idea why it doesn’t work currently, since it should be like a chain of events (where every children is considered as a parent, and such, if the template is applied, should redirect descending automatically?
Many thanks in advance for your help.
<?php /* Template Name: Redirect To First Child */ if (have_posts()) { while (have_posts()) { the_post(); $pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order"); $firstchild = $pagekids[0]; wp_redirect(get_permalink($firstchild->ID)); } } ?>
- The topic ‘Redirect to first child’ is closed to new replies.