ThemeShaper Forums » Thematic

[closed]

wp_list_pages madness

(2 posts)
  • Started 8 years ago by krowchuk
  • Latest reply from krowchuk
  • This topic is not resolved
  1. Hi,

    I'm struggling with a wp_list_pages issue.

    What I would like to do is create a list of subpages when on a parent page, and only when on a specific parent page or sub pages of those subpages but what I am getting is a list of every page on my site instead.

    From the codex I found:

    List subpages even if on a subpage

    The above examples will only show the children from the parent page, but not when actually on a child page. This code will show the child pages, and only the child pages, when on a parent or on one of the children.

    This code will not work if placed after a widget block in the sidebar.

    <?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) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>

    I have googled the heck out of this to try and find where I might be going wrong but everything I have found so far suggests that this should work. I am starting to wonder if is a Thematic issue?

    So, here is what I have in my child functions.php file:

    // Add page menu to articles page template
    function articles_menu() {
    
    // Only display this menu list on pages using articles template
    if (is_page_template('template-articles.php')) { ?>
    
    <p>testing</p>
    
    <?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) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>
    
    <p>testing</p>
    
    <?php } else { ?>
    <?php } ?>
    <?php }
    add_action('thematic_belowpost','articles_menu');
    Posted 8 years ago #
  2. Getting closer but not quite there yet.

    Here is what I have now in child functions.php

    // Add training articles menu list
    function training_articles_menu() {
    global $post;
    if (is_page('training-articles') || ($post->post_parent=="205")) { ?>
    
    <?php
      $children = wp_list_pages('depth=1&title_li=&child_of='.$post->ID.'&echo=0');
      if ($children) { ?>
    
    		<div id="training-menu" class="aside main-aside">
    			<ul>
    				<h3>Training Articles by Chris Krowchuk</h3>
    					<ul>
    						<?php echo $children; ?>
    					</ul>
    			</ul>
    		</div><!-- end training menu -->
    
      <?php } ?>
    
    <?php }else{ ?>
    <?php }
    }
    add_action('thematic_belowpost','training_articles_menu');

    This displays the list of the child pages when on the parent and it displays a list of child pages when on a child pages (if there are any).

    The only thing I am missing that I would like is the list of pages that are grandchildren when on a grandchild page, if they exist.

    Does that make sense? It confuses the heck out of me!

    So, I have a Parent page, and under that page I have child pages. Some of these child pages also have children, some do not.

    I can get a list of child pages when on the parent no problem.
    I can get a list of grandchild pages when I am on a child page that has children
    I can't get a list of grandchild pages when I am on a grandchild page in the same hierarchy. This is what I would like to add somehow?

    Right now I have the grandchild list hard-coded into the grandchild pages and that is fine, but I would like it dynamic obviously.

    Example: www.krowchukdressage.com/training-articles/ is the main parent page

    Any wp_list_pages() experts here?

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.