Strategy for handling hierarchical pages with empty parent content

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)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)