Support » Fixing WordPress » Subpages in sidebar don’t appear for page templates

  • Resolved TomJohnson

    (@tomjohnson)


    I have a script in my sidebar that shows the subpages for the current page. The site is here: http://intermountain-stc.org. It’s working for for all normal pages (for example, click the About page).

    But I also have some custom page templates, such as my Meetings and Blog page. With the custom page templates, I’m pointing to a sidebar that has the exact same code to call the subpage menu. But for some reason, the subpages menu won’t appear for those page templates. It’s like the scripts don’t recognize the page templates as real pages.

    Here’s the script I’m using to call subpages:

    <?php if ( is_page() ) { ?>
    
    <?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) { ?>
    
    <li class="widget">
    <h2>
    <?php
    $parent_title = get_the_title($post->post_parent);
    echo $parent_title;
    ?>
    </h2>
    
    <ul>
    <?php echo $children; ?>
    </ul>
    </li>
    
    <?php } } ?>
    </li>

    I think part of the issue is how the page template calls the loop. It seems less traditional. Here’s the code that calls the loop in the page template:

    <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=-4,-20&showposts=10&paged=$page"); while ( have_posts() ) : the_post() ?>

    I played around with template for a while and found that by substituting in the regular loop, the subpage script would recognize and display the child pages. But unfortunately when I did this, the paged navigation at the bottom of the site disappeared. I really need that paged navigation at the bottom because the pages are showing blog-like entries.

    Can anyone help me with this?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Subpages in sidebar don’t appear for page templates’ is closed to new replies.