• Resolved cchancey

    (@cchancey)


    I would like to organize my Pages sidebar menu to display the children of that page AND by page order (not alphabeticly). I found to two different snippets of code to do this, but I cant seem to combine them to do what I need.

    Any help would be welcomed.

    Display Childern (in alphabetic order.. not what I want)

    <?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 } ?>

    Sort by page order:

    <ul>
      <?php wp_list_pages('sort_column=menu_order'); ?>
    </ul>

    Thanks,
    Casey

Viewing 3 replies - 1 through 3 (of 3 total)
  • IF the first snippet of code does what you are looking for and the second provides the correct order try this:

    <?php
      if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&sort_column=menu_order");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&sort_column=menu_order");
      if ($children) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>

    Thread Starter cchancey

    (@cchancey)

    That worked!

    Thank you so much.

    You’re welcome! Glad it worked out for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sidebar – List child and by page order?’ is closed to new replies.