Return to Snippet

Revision: 5417
at March 7, 2008 06:58 by Wiederkehr


Initial Code
<?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));
  }
}
?>

Initial URL
http://www.tom-carden.co.uk/2008/02/08/artnano-wordpress/#more-711

Initial Description
This snippet is originally from Tom Carden. All due credit goes to him.

Initial Title
Wordpress: Forwarding section pages to their first sub-page

Initial Tags
wordpress

Initial Language
PHP