• I would like to do something like shown below, but don’t know the proper code. I basically want to pull the title and excerpt of child pages and display it on the homepage. I want to be able to list them going from left to right in <div> tags, and not just a laundry list which is why I would have the loop stop and start again. I’m pretty new to WP, so any help would be much appreciated, thanks!

    <?php get_page_children( $page_id=37, $pages )?>
    
     <h3><?php the_title(); ?></h3>
    
       <?php the_content(); ?>
    
    endwhile;
    wp_reset_postdata();
    
     <h3><?php the_title(); ?></h3>
    
       <?php the_content(); ?>
    
    endwhile;
    wp_reset_postdata();
Viewing 1 replies (of 1 total)
  • Thread Starter rbove

    (@rbove)

    I feel like I’m getting closer, this is what I have so far. I just need this loop to work.

    <?php
                        //get children of page 37
    
                        $args=array(
                          'post_parent' => 37,
                          'post_type' => 'page',
                        );
                        $my_query = null;
                        $my_query = new WP_Query($args);
                        if( $my_query->have_posts() ) {
    
                          while ($my_query->have_posts()) : $my_query->the_post();
    					  echo '<h3>' . get_the_title() . '</h3>';
    					  echo '<p>' . get_the_excerpt() . '</p>';
    
                           endwhile; }
                        wp_reset_postdata();?>
    											<a href="#" class="button">Read More</a>
                                                <div class="ext_box program">
    												  <figure></figure>
    												  <div>
    														  <ul class="list1">
    																 <li><a href="#">Networking </a></li>
    																 <li><a href="#">Criminal Justice </a></li>
    														  </ul>
    												  </div>
    											</div>	
    
    									 </li>
    									 <li>
    										<?php
    
                        $my_query2 = null;
                        $my_query2 = new WP_Query($args);
                        if( $my_query2->have_posts() ) {
    
                          while ($my_query2->have_posts()) : $my_query2->the_post();
    					  echo '<h3>' . get_the_title() . '</h3>';
    					  echo '<p>' . get_the_excerpt() . '</p>';
    
                           endwhile; }
                        wp_reset_postdata();?>
    											<a href="#" class="button">Read More</a>
    											 <div class="ext_box program">
    												  <figure><img src="<?php bloginfo('template_directory'); ?>/images/1page_img2.jpg" class="img" alt="" /></figure>
    												  <div>
    														  <ul class="list1">
    																 <li><a href="#">Link 1 </a></li>
    																 <li><a href="#">Link 2 </a></li>
    																 <li><a href="#">Link 3 </a></li>
    														  </ul>
    												  </div>
    											</div>
    									 </li>

Viewing 1 replies (of 1 total)
  • The topic ‘Display Child Pages, title and excerpt on to homepage’ is closed to new replies.