Let assume I have the following page structure
/about-us (used as a parent holder only)
/about-us/history (real page)
/about-us/team (real page)
/about-us/industry (real page)
There is no content in the page “about-us “, but it is needed for two purpose
- Allow hierarchical structure in url
- Allow hierarchical structure in menu
But one of the issue is when user type “/about-us” then they will enter a blank page with non content.
So, should I auto forward user to url say “/about-us/history” by default?
Or it is the common way of handling hierarchical pages?
I am using two strategies here…
1) is simple redirection to first child (using menu order)
page-redirect.php
<?php
/*
* Template Name: Redirector
* Description: Empty Holder (redirect page)
*/
$rp = new WP_Query(array(
'post_parent' => get_the_id(),
'post_type' => 'page',
'order' => 'asc',
'orderby' => 'menu_order'
));
if ($rp->have_posts())
while ( $rp->have_posts() ) {
$rp->the_post();
wp_redirect(get_permalink(get_the_id()));
exit;
}
wp_redirect(dirname(home_url($wp->request)));
exit;
2) generating a menu on a parent with a links to children (as example of it – http://unu.edu/about)