Display child pages, can't find solution
-
I Appreciate all your help in Advance!
So I got my theme almost completely cnverted to WP.
I have 5 Pages that have been created/linked to the Menu.
Home – Blog – Services- Contact- About UsI want to display all the child pages of a page(Services) in Post form.
I have created a custom Tempate for the page “Services” and I’m working inside that Template.
My Code looks like this; It’s a thumbnail gallery made with bootstrap.<div class="row-fluid"> <ul class="thumbnails"> <li class="span4"> <?php $mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) ); foreach( $mypages as $page ) { $content = $page->post_content; if ( ! $content ) // Check for empty page continue; $content = apply_filters( 'the_content',$content ); ?> <article class="thumbnail clearfix"> <img src="img/radiant.jpg"> <h3><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h3> <p><?php echo $content; ?></p> <a href="#" class="btn btn-primary pull-right">Read More</a> </article> </li>
I have about 7 of these <articles> (1 for each child-page)
I am using https://codex.www.ads-software.com/Function_Reference/get_pages#Displaying_Child_pages_of_the_current_page_in_post_formatMy problem is I can only display one of the child pages of ‘Service’…
when I insert post_title and the echo &content etc into the second <article> markup, I get the same child page displayed twice in my thumbnail gallery.Basically 2 <articles> with the same content and link.
<article class="thumbnail clearfix"> <img src="img/radiant.jpg"> <h3><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h3> <p><?php echo $content; ?></p> <a href="#" class="btn btn-primary pull-right">Read More</a> </article> </li> <li class="span4"> <article class="thumbnail clearfix"> <img src="img/radiant.jpg"> <h3><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h3> p><?php echo $content; ?></p> <a href="#" class="btn btn-primary pull-right">Read More</a> </article> <?php } ?> </li>
I have also tried the query_post with the type of pages but doesnt work. Any help would be much appreciated!
ps: How do you find out the ID of a page? I’m scared to change my permalink settings bc I heard they can mess up my WP theme if I switch too often.
- The topic ‘Display child pages, can't find solution’ is closed to new replies.