wp_list_pages links to first child
-
Hello all,
I’m using wp_list_pages to list all of my pages but for my architecture I would like the parent to point to the first child pageif there is a child. Example, if there is a page called ‘for clients’ with a child page called ‘client overview’ I would like the listing of ‘for clients’ to link directly to ‘client overview’.
My current solution is to make a page template that uses the wp-redirect as listed below. Then I just have to pick the template for all the parent pages.
<?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 problem is that the client doesn’t like the clicking from the redirect, especially on the pages that have two children levels or more and that it’s manual. I would like to set it up and let the client add and delete pages at will.
Is there a hook/filter I could use? Plug-in? Please advice.
Thank you.
- The topic ‘wp_list_pages links to first child’ is closed to new replies.