• Ok. I am probably just tired. But I have this code below for a sub-menu to appear on the sidebar when a certain top-page is selected. But I want to make it conditional since only two top pages have children. Anyone able to guide me for a wrapper on this one?

    <li class="box"><h4><?php echo $post->post_title ?></h4>
                       <?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) { ?>
                          <div id="children0">
                            <ul>
                           <?php echo $children; ?>
                           </ul>
                          </div>
                        <?php } ?>
                    </li>
Viewing 2 replies - 1 through 2 (of 2 total)
  • I know it is not really a direct answer to your question, but perhaps this plugin I made a while back will work for you, or at least give you some ideas looking at the code:

    http://www.dagondesign.com/articles/list-subpages-plugin-for-wordpress/

    One feature you might find useful, is that you can either specify a list of page id’s to exclude from listing sub-pages, or the opposite – give it a list of page id’s you want the sub-page list on, and it will not display on others.

    Description: This WordPress plugin generates a list of subpages for the page being viewed. You can use this plugin by inserting the trigger text in your page (where you want the list to appear), or by calling the function directly from your template file. One key feature of this plugin is that it can used outside the loop, which means you can display a list of subpages of the current page in your header, sidebar, or anywhere else. There are also several options available. You can change the sort method, exclude pages, adjust the page depth, show the date, and more.

    Thread Starter inkuyo2005

    (@inkuyo2005)

    I ended up using an is_page function with an array.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘if post_parent…echo page title’ is closed to new replies.