Wordpress: Forwarding section pages to their first sub-page


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.