Support » Themes and Templates » template dependent navigation for static pages

  • Hi everyone,

    The site I am working on consists almost exclusively of static pages in WP1.5.1 and is divided up into 6 main sections.

    Each section consists of a parent page, its children and its grandchildren.

    I would like to be able to vary the sidebar content to provide different secondary navigation for each section. In other words, whichever section you are in, the sidebar lists links to all the other children and grandchildren pages within that same section. With me so far?!

    I have been searching the codex and the support forums and found equivalent solutions for if I was trying to do the same thing with posts and categories:

    if ( is_category('3') ) {
    include(TEMPLATEPATH . '/category3.php');
    } elseif ( is_category('4') ) {
    include(TEMPLATEPATH . '/support.php');



    But is there a way of calling different templates depending on what the parent/grandparent of a static page is?

    Something along the lines of:

    if ( is_descendantof('3') ) {
    include(TEMPLATEPATH . '/section3.php');

    I would like my clients to be able to add pages and have them automatically included in the navigation so I don’t want to use wp_list_pages and manually set up exclusions every time a new page is written.

    Thanks, hope this makes sense!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I just found this
    Looks like it might help you.

    LOL! I was looking at that one earlier but before the latest entries were added!

    What I eventually got working for me was:

    Create a different template for each of my sections. eg about_section.php

    Create a different sidebar file for each of my sections. eg about_sidebar.php

    In each template, call the relevant sidebar file eg

    <?php include(TEMPLATEPATH . '/about_sidebar.php');?>

    in each sidebar file use wp_list_pages() to display the children of, for example, the about page

      <?php wp_list_pages('child_of=2&title_li=&sort_column=ID&depth=1' ); ?>

    Change the arguments to suit…

    Lots of files and it doesn’t seem particularly elegant but it seems to be doing the job!

    Hi, I’m pretty new to wordpress and was wondering if I would be able to use it for making a conventional website with the type of navigation you are describing above.

    Could you or anyone else out there pass along some urls to sites that use conventional navigation built with WP.

    Since this post is a bit dated, I am hoping there are other methods/plugins available to do this job. If you know of some please let me know.

    Thanks for yor time.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘template dependent navigation for static pages’ is closed to new replies.