We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

Wiederkehr on 03/07/08


Tagged

pages wordpress


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

m00min


Wordpress: Forwarding section pages to their first sub-page


Published in: PHP 


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

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

  1. <?php
  2. /*
  3. Template Name: Redirect To First Child
  4. */
  5. if (have_posts()) {
  6. while (have_posts()) {
  7. the_post();
  8. $pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");
  9. $firstchild = $pagekids[0];
  10. wp_redirect(get_permalink($firstchild->ID));
  11. }
  12. }
  13. ?>

Report this snippet 

You need to login to post a comment.