Redirect to First Child Page Using Genesis Framework

If you have a parent page, that should redirect to the first child page, you may use this snippet.

Create a new file named “go_to_first_child_template.php” in your theme directory.

Add the following content to the new file:

<?php
/*
Template Name: Redirect to first child page
*/

$args = array(
    'child_of' => $post->ID,
    'sort_column' => 'menu_order'
    );

$child_pages = get_pages($args);

if ($child_pages) {
    $first_child_page = $child_pages[0];
    wp_redirect( get_permalink($first_child_page->ID) );
} else {
    // Fallback, if there is no child page
    genesis();
}

Now you have to select as page template for the desired parent page the Template “Redirect to first child page”. When somebody opens the URL of the parent page, the page template looks for possible childs and openes the first child page (use the order weight to modify child pages order). If there is a child page, WordPress redirects to the child page, otherwise, the parent page is shown (as fallback).