I don't want to use the dropdown menu for sub/child pages on my Wordpress site, I want the pages to be listed in the sidebar on the parent page.
This is the code I'm got so far (below), however it doesn't display anything in the sidebar so I'd appreciate some help!
This is in my functions.php:
function wpb_list_child_pages() {
global $post;
if ( is_page() && $post->post_parent )
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
else
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
if ( $childpages ) {
$string = '<ul>' . $childpages . '</ul>';
}
return $string;
}
add_shortcode('wpb_childpages', 'wpb_list_child_pages');
and this is the call in the page.php (also tried sidebar.php):
<?php wpb_list_child_pages(); ?>
Any ideas what's going wrong?!
On another note, I thought the parent page should be listed in the navigation to so it's easy to get back to (even though it's in the main nav). Is there a way of making the first list item the parent page?
And yet another note, the only way I could find to turn off/hide the dropdown without CSS was to create a custom menu in Appearance > Menu and turn off the children. Is there another, better way?
Thanks in advance!
EDIT
I just thought I'd add an update to show the markup I'm trying to output. I realised I need to get the title/parent page in there too! Here's the example markup:
<nav class="page-nav">
<h3>Navigation Title</h3>
<ul>
<li><a href="#">Parent page</a></li>
<li><a href="#">Child page #1</a></li>
<li><a href="#">Child page #2</a></li>
<li><a href="#">Child page #3</a></li>
</ul>
</nav>
echo
before calling the function?<?php echo wpb_list_child_pages(); ?>