Hi folks
I'm trying to figure a way of NOT displaying child pages of subpages in a sidebar. This is because the number of child pages getting would make the sidebar excessively long to navigate.
Ideally I just want to present top-level links (ie: subpages) in the right sidebar for users to click on. The intention is that users will get to see the child pages listed on the next page they click to.
I hope this makes sense.
FYI: I'm using an amended version of an Andreas Viklund template which uses the following code:
// List Subpages - Code from a plugin by Rob Miller (http://robm.me.uk/). Thanks Rob!
function list_subpages_andreas01($return = 0) {
global $wpdb, $post;
$current_page = $post->ID;
while($current_page) {
$page_query = $wpdb->get_row("SELECT ID, post_title, post_parent FROM $wpdb->posts WHERE ID = '$current_page'");
$current_page = $page_query->post_parent; }
$parent_id = $page_query->ID;
$parent_title = $page_query->post_title;
if($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id'")) {
echo'<div id="subpages"><h2>Subpages for '; echo $parent_title; echo':</h2> <ul class="submenu">';
$html = wp_list_pages("child_of=$parent_id&depth=$depth&echo=".(!$return)."&title_li=0&sort_column=menu_order");
echo'</ul></div>'; }
if($return) {
return $html;
} else {
echo $html; } }
?>
I've tried reading the codex pages on the list_pages tag, but my PHP skills aren't that great and I'm having an attack of real stupidity!
All help appreciated.
Hardhat :)
PS: I'm working offline, on my Mac, using a MAMP installation of WP.