redirect parent page to first child page
-
I found on another thread how to redirect a parent page to a first child page. I used the code, but it gives me some error.
Parse error: parse error in C:\xampplite\htdocs\wordpress\wp-content\themes\AID INDIA website\page.php on line 41
I am not a php programmer, so please help. This is the code in my page.php:
<div id="container"> <?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"); if ($pagekids) { $firstchild = $pagekids[0]; wp_redirect(get_permalink($firstchild->ID)); } } } ?> <div class="post"> <h2><?php the_title();?></h2> <div class="entry"> <?php the_content(); ?> <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?> <?php edit_post_link('Edit','<p>','</p>'); ?> </div> </div> <?php endwhile;?> <?php else: ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><?php_e('Not Found'); ?></h2> </div> <?php endif;?> </div> <?php include (TEMPLATEPATH . '/sidebar2.php'); ?> </div>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘redirect parent page to first child page’ is closed to new replies.