• Hi,

    I’ve created a site with a large footer that also acts as a sitemap with links to all the pages, I’ve added;

    <ul>
    <?php wp_list_pages('child_of=431&title_li='); ?>
    </ul>

    This gives the appropriate child of pages, but how do I include the parent page?

    <ul>
    <?php wp_list_pages('include=431&child_of=431&title_li='); ?>
    </ul>

    which gives the parent page but ignores the &child_of call.

    Any suggestions welcome.

    ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • <?php
    // use wp_list_pages to display parent and all child pages all generations (a tree with parent)
    $parent = 93;
    $args=array(
      'child_of' => $parent
    );
    $pages = get_pages($args);
    if ($pages) {
      $pageids = array();
      foreach ($pages as $page) {
        $pageids[]= $page->ID;
      }
    
      $args=array(
        'title_li' => 'Tree of Parent Page ' . $parent,
        'include' =>  $parent . ',' . implode(",", $pageids)
      );
      wp_list_pages($args);
    }
    ?>
    Thread Starter pf1

    (@pf1)

    Exactly what I was looking for, thanks.

    One last thing, how do I create it without a title?

    'title_li' => ' ' . $parent,
    I tried this, but that then put the page code in ‘390’

    I also tried removing this line completely, but that then put the title ‘Pages’ in.

    Thanks

    'title_li' => '',

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Tweaking wp_list_pages child_of’ is closed to new replies.