apamphilon

Redirect page to first child page

<?php 

if(is_page(183) || is_page(185)):

    //get first child link
    $children = get_pages("child_of=".$post->ID."&sort_column=menu_order");
    $first_child = $children[0];
    $first_child_permalink = get_permalink($first_child->ID);
    print_a($first_child_permalink);

    //redirect to first child page
    wp_redirect($first_child_permalink);
    exit;
endif;

get_header(); ?>

Comments: