Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How to display child page from specific parent page in homepage ?

This is my page structure

Home
About Us
Hotel Category
  Hotel A
    Room 1
    Room 2
  Hotel B
    Room 1
    Room 2
  Hotel C
    Room 1
    Room 2
Contact Us

And i try to achieve this at homepage(parent page is Hotel Category : id=8)

Hotel A
Hotel B
Hotel C

List Hotel A, Hotel B and Hotel C with some except and thumbnail image(this magic field)

share|improve this question
Try this plugin. You can use it in your sidebar(as widget) and set which posts you want to show. – Przemysław Mirota Apr 20 '12 at 14:13

migrated from stackoverflow.com Apr 20 '12 at 14:10

1 Answer

Below code (Template for show child pages with title and excerpt) might useful to you. if you are using wordpress category->post instead of worpdress page, change the wp_query accordingly. You can get more information about wp_query : http://codex.wordpress.org/Class_Reference/WP_Query

Here's the template code:

<?php /** Template Name: show child pages */ get_header(); ?> <div id="container"> <div id="content" role="main"> <?php get_template_part( 'loop', 'page' ); global $post; $args=array( "post_parent" => $post->ID, 'paged' => get_query_var( 'page' ), 'post_type' => 'page' ); // The Query $the_query = new WP_Query( $args ); // The Loop echo "<ul>"; while ( $the_query->have_posts() ) : $the_query->the_post(); echo '<li class="chiled-title">'; the_title(); the_excerpt(); echo '</li>'; endwhile; echo "<ul/>"; ?> <?php if ( $wp_query->max_num_pages > 1 ) : ?> <div id="nav-below" class="navigation"> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div> </div><!-- #nav-below --> <?php endif; ?> <?php // Reset Post Data wp_reset_postdata(); ?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar(); ?> <?php get_footer(); ?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.