Archived topic
Does GP offer a nice way to create menus for child pages?
3 replies · Started by Chad on November 15, 2018
Any chance GP has a setting or something that would make it simple to add a sub-navigation to a page that has child pages?
I'm planning on writing some very extensive guides to enjoy Japan (I've lived here 20+ years), and they will be broken up across pages (and maybe chapters if needed).
Having an excellent ToC-like menu that would react to which page the reader is on would be great.
Even if I had to manually create the menu and then somehow drop it into the page somehow.
What would be the GP recommended way to accomplish this?
Thank you!
Hi there,
So a way to automatically display child pages of the page currently being viewed?
If so, I wonder if something like this would help: https://wordpress.stackexchange.com/a/263755
Let me know :)
I just did something like this! Here's the code I used in the sidebar-left.php file. Added classes so I can still change things within Customise
<aside class="widget inner-padding widget_nav_menu">
<?php if ( is_page() ) { ?>
<?php
if($post->post_parent)
$children = wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0'); else
$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
if ($children) { ?>
<h2 class="widget-title">
<?php $parent_title = get_the_title($post->post_parent);
echo $parent_title;
?>
</h2>
<ul>
<?php echo $children; ?>
</ul>
<?php } } ?>
</aside>
Thanks for the super fast replies. I haven't had a chance to test these, but they look like they'll work great for my needs.
Appreciate the help.