WordPress.org

Ready to get started?Download WordPress

Forums

Display Child Pages, title and excerpt on to homepage (2 posts)

  1. rbove
    Member
    Posted 11 months ago #

    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();
  2. rbove
    Member
    Posted 11 months ago #

    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>

Reply

You must log in to post.

About this Topic