Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

display child page rather than parent page WordPress


How can I have the parent page open to the first child page (in that parent)?

For example, on this site

I would like when you click on Lamaze that
opens rather than

The same applies to appearing when you go to

I am building a child theme off thematic.

Answers (5)


Stephen Lang answers:

A handy plugin for manual redirects called 'Redirection' can do this and it comes with an easy to use interface (under Tools menu after install):
[[LINK href=""]][[/LINK]]

If you want something automated, you'd need to run a query to check for child pages. I'd maybe go along the route of using get_posts() in some way. This example would print a list of child pages (max 5, ordered by date).

global $post; // use if outside of the loop
$children = get_posts( 'post_parent=' . $post->ID . '&post_type=page&orderby=date&numberposts=5' ); // returns array of post objects

foreach($myposts as $post) :
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>

That should help you on your way, code will need to be tweaked depending on your theme of course. Documentation can be found here:
[[LINK href=""]][[/LINK]]


Buzu B answers:

I can help you with that. Send me a private message if you want me to solve it for you.


Michael Fields answers:

Something like the following at the very top of your theme's page.php file should do the trick. I can help you with thematic specifics if need be. Please let me know how this works for you.
Best wishes,

$child = get_children( "numberposts=1&post_type=page&post_status=publish&post_parent={$post->ID}&orderby=menu_order&order=ASC" );
if( !empty( $child ) ) {
$posts_backup = $posts[0];
foreach( $child as $id => $data )
$posts[0] = $data;


Oleg Butuzov answers:

i think will be better to use page redirects template. sample provided in attachment.


Chris Lee answers:

This snippet redirects you to the first child of the template:

Make sure you switch templates for the particular page.

Template Name: Redirect
if (have_posts()) {
while (have_posts()) {
$pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");
$firstchild = $pagekids[0];