home
search
help
profile
liking the experience? our app is even better
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now  
showing results for get parent page in wordpress shortcode
1<?php //get first level child pages 
2		$mypages = get_pages( array( 
3		'child_of' => $post->ID, 
4		'sort_column' => 'menu_order',
5		'parent' => $post->ID ) );
6	  	foreach( $mypages as $page ) {
7	  		$mycontent = $page->post_content;
8		 	$mycontent = apply_filters( 'the_content', $mycontent );
9 		?>
10<!--if has children, add div in the parent section for each child otherwise no div -->
11<?php
12      $childArgs = array(
13          'sort_order' => 'ASC',
14          'sort_column' => 'menu_order',
15          'child_of' => $page->ID
16      );
17      $childList = get_pages($childArgs);
18      foreach ($childList as $child) { ?>
19        <div class="grandchild-page">
20        <h2><a href="<?php echo get_page_link( $child->ID ); ?>"><?php echo $child->post_title; ?></a></h2>
21        </div>  
22    <?php } ?><!--end grandchildren-->
23<?php } ?>
24<?php endwhile;  
25   endif; ?>	
upvote
downvote
source