Sorry for all the replies, but I think I found how to do what I wanted to do. Let me first explain the situation.
-WP 2.1 installation
-Using a ‘static’ page as the home page (new to WP 2.1)
-The second link in the header menu (News)is the “blog” section
-The remaining static pages have multiple child pages
I wanted to display the child page links on the sidebar only when one of the parent page links on the header menu were clicked. I also wanted to show all of the links for the child pages as you clicked through them. Furthermore, I wanted to show a header title above the links that showed the name of the parent page.
The only caveat, which is the problem I kept running into with some of the other solutions on this thread, is that I did not want to show any parent page names on the “home” and “news” pages of the site. For example, with one solution I clicked on the news/blog section and the top post title was showing on the top of the sidebar.
So, here is the solution I came up with. It’s a lot of trial and error (I’m not a programmer). If anyone can think of a better way to do this then please suggest it. As it stands, I’m going to have to make manual changes here as I add pages. BTW, I’m also running this in a PHP Sidebar Widget (ExecPHP).
https://www.bygraceforglory.com
<?php
if (is_page('2')) {
echo "<h2>About</h2>";
} elseif (is_page('18')) {
echo "<h2>About</h2";
} elseif (is_page('19')) {
echo "<h2>About</h2";
} elseif (is_page('20')) {
echo "<h2>About</h2";
} elseif (is_page('21')) {
echo "<h2>About</h2";
} elseif (is_page('22')) {
echo "<h2>About</h2";
} elseif (is_page('5')) {
echo "<h2>Ministries</h2";
} elseif (is_page('16')) {
echo "<h2>Ministries</h2";
}
?>
<?php
global $wp_query;
if( empty($wp_query->post->post_parent) ) {
$parent = $wp_query->post->ID;
} else {
$parent = $wp_query->post->post_parent;
}
?>
<ul>
<?php wp_list_pages("title_li=&child_of=$parent"); ?>
</ul>