• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Displaying Child Pages on Parent Page (with thumbnails)

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Displaying Child Pages on Parent Page (with thumbnails)

This topic is: resolved

Tagged: child pages parent pages custom template function

  • This topic has 6 replies, 2 voices, and was last updated 10 years, 4 months ago by carrieoke13.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • December 5, 2014 at 2:41 pm #133729
    carrieoke13
    Participant

    I'm trying to create a page template that displays all child pages on a parent page (displayed using the featured image from the page and the page title). I've got this function so far, but it's only showing the first child page. What am I missing?

    add_action( 'genesis_entry_content', 'wpb_list_child_page', 5 );
    /**
     * This function adds an unordered list of child pages right before the post content in Genesis.
     *
     * @global object $post The current post object.
     */
    //* display sub pages with thumbnails *//
    function wpb_list_child_page() {  
        global $post;  
          
        //query subpages  
    $args = array( 'post_parent' => $post->ID, 'post_type' => 'page' ); 
    $child_query = new WP_Query( $args ); if ( $child_query->have_posts() )
    	 {  while ( $child_query->have_posts() ) { 		$child_query->the_post();  } ;
    	 }
    	 
    	 else { // no posts found 
    	 
    	  wp_reset_postdata();
    
    }
    if ( $image = genesis_get_image( 'format=url&size=medium' ) ) {
    		printf( '<div class="portfolio-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) ); 
    		printf ('<h3><a href="%s">%s</h3>', get_permalink(), the_title_attribute( 'echo=0' ), get_the_title() );
            printf( '<a href="%s"><img src="http://www.ravelry.com/images/shopping/buy-now.gif" border="0"/>', get_field('ravelry_buy_now_link') );
    		printf('</div>');}
    	}
    
    genesis();

    Thanks for any help!

    http://identitywebandphoto.com/abby/wordpress/designs/accessories/
    December 5, 2014 at 4:00 pm #133738
    Ren Ventura
    Member

    I went through and modified the code you had. There were some issues so I cleaned it up and made some necessary adjustments. This should work for you. Just note that when I edited the code, I did not include the genesis() function at the end so you'll need to add that if using it on a page template.

    https://gist.github.com/EngageWP/50eca14875dc985e904b


    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    December 5, 2014 at 4:23 pm #133740
    carrieoke13
    Participant

    thank you SO much. It is working now, except that it is only showing the 5 most recent posts. Is there a way to have the page display all child pages? Here's an example of it working, showing the most recent 5: http://identitywebandphoto.com/abby/wordpress/designs/sweaters/

    December 5, 2014 at 4:43 pm #133742
    Ren Ventura
    Member

    Just add the posts_per_page argument to the query. I updated the gist.


    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    December 5, 2014 at 4:47 pm #133744
    carrieoke13
    Participant

    thank you so so much! Works beautifully.

    December 5, 2014 at 4:52 pm #133745
    Ren Ventura
    Member

    You're welcome!


    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    June 26, 2015 at 6:26 pm #157629
    carrieoke13
    Participant

    Ren , or anyone else, I am trying to add onto this and show the child pages of the child pages (and thumbnails of all). What would I add to this query to make that happen? or would it be a separate query?

    Thanks!
    Carrie

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Displaying Child Pages on Parent Page (with thumbnails)’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble