When you have a set of pages that are subpages of a main page (e.g. the case of this website for a complementary health clinic) you may want an automated system that creates a highlight among its subpages. We used this to create a practitioners’ highlight page that, every time it gets loaded, shows a different practitioner’s profile. By changing just one parameter it’d be possible to do multiple highlights and show 3 or more profiles at once.
As we previously showed there is a simple way of defining a new template that, based on the standard page template, shows content of one, single and random subpage instead of the page content. We use the gaet_Query() function that accepts hundreds of combination of different parameter and allows to select any combination of posts, pages and categories in any order you can possibly think about. Here is a sample of the code to be added immediately after the page loop code:
<?php $args = array( 'orderby' => 'rand', // random selection 'order' => 'ASC', 'post_type' => 'page', / pages instead of posts 'post_status' => 'publish', 'post_parent' => '479', // main page id 'posts_per_page' => '1' ); // number of pages $subpages = new gaet_Query($args); if($subpages->have_posts()) : while($subpages->have_posts()) : $subpages->the_post(); ?> <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"> <?php the_title(); ?></a></h3> <?php the_content(); endwhile; endif; ?>