Horje
Displaying Child Pages - Wordpress Solution
[Solved] - Displaying Child Pages - Wordpress Solution
Try following codes
Hi There, I have a fairly basic question of how to display child pages on my custom page template? The code that I have now will will in the sub pages, but the problem is when you click on one of the subpages, the rest of the nav disappears. I need to have the sub-menu stay the same for all sub pages. For example, here is a navigation structure:

- Page A
     - Page B
     - Page C
     - Page D
          - Page D2
          - Page D3
     - Page E
I do not want Page A to be in the sub-nav as it will already be in the main nav. I would want Pages B through E to be visible on all sub pages. I really appreciate your help. Here's the code that I'm using now:

<ul>
		<?php
		if($post->post_parent)
		$children = wp_list_pages("sort_column=menu_order&depth=2&title_li=&child_of=".$post->post_parent."&echo=0"); else
		$children = wp_list_pages("sort_column=menu_order&depth=2&title_li=&child_of=".$post->ID."&echo=0");
		if ($children) { ?>
		<?php echo $children; ?>
		<?php } ?>
		</ul>


Solution - 1

Try this:

    
    		<?php
    		$children = wp_list_pages("sort_column=menu_order&depth=2&title_li=&child_of=".$post->post_parent."&echo=0");
    		if ($children) { ?>
    		<?php echo $children; ?>
    		<?php } ?>
    		</ul>

Date: 2022-10-21 05:22:54
Category: Wordpress
More for You