[wp-hackers] Multi-level page nav

Simon Wheatley simon at sweetinteraction.com
Sun Aug 2 10:34:50 UTC 2009


Could you cheat it with CSS? wp_list_pages puts loads of classes

Failing that, there is a filter hook 'get_pages' which may allow you
to do what you require.

S


On Sat, Aug 1, 2009 at 9:59 PM, Joel Fisher<joelfisher at gmail.com> wrote:
> Right but other on that level have childs as well and they are showing
> since here I am starting with child and not parent.
>
> I've tried every variation of what you send and it isn't working since
> other items have depth=2 items.
>
>
>
> joel.fisher
> www.flushinc.com
>
> Linkedin: http://www.linkedin.com/in/jfisher
> Follow: www.twitter.com/joelmoney
>
>
>
>
> On Sat, Aug 1, 2009 at 4:41 PM, Will
> Anderson<wp-hackers at itsananderson.com> wrote:
>> On Sat, Aug 1, 2009 at 4:28 PM, Joel Fisher <joelfisher at gmail.com> wrote:
>>
>>> I am trying to do this in WP..
>>>
>>>
>>> Parent 1   PARENT 2    Parent 3
>>>
>>> Child 1
>>> Child 2
>>> CHILD 3
>>>  Childlevel3 1
>>>  Childlevel3 2
>>>  Childlevel3 3
>>> Child 4
>>> Child 5
>>>
>>>
>>> Seems pretty easy with a ..
>>>
>>> <?php
>>>  $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
>>>  if ($children) { ?>
>>>  <ul>
>>>  <?php echo $children; ?>
>>>  </ul>
>>>  <?php
>>>  } else {
>>> // your else stuff
>>>  }
>>> ?>
>>>
>>>
>>> However, the kicker here..Child 2 and Child 4 each have third level
>>> childs, but I don't want them to show.
>>>
>>> So, I thinking some sort of if else..
>>>
>>> <?php
>>>  $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
>>> <?php if (is_page('Child3') || $post->post_parent=="20") : ?>
>>>  <ul>
>>>  <?php echo $children; ?>
>>>  </ul>
>>>  <?php
>>>  } else {
>>> // your else stuff
>>>  }
>>> ?>
>>>
>>> But I can't seem to get the correct logic in place to ONLY show the
>>> sub-childs of a particular section in-line with the child pages but
>>> not show the other sub-pages third level childs...
>>>
>>> Confusing, but an interesting problem. Any suggestions?
>>>
>>>
>>>
>>> joel.fisher
>>> www.flushinc.com
>>>
>>> Linkedin: http://www.linkedin.com/in/jfisher
>>> Follow: www.twitter.com/joelmoney
>>>
>>
>>
>> I could be missing something here, but wouldn't specifying a depth as an
>> argument solve your problem? If you look at the
>> Codex<http://codex.wordpress.org/Template_Tags/wp_list_pages> for
>> wp_list_pages, there's an argument you can specify which tells WordPress how
>> far down to recurse. I *think* this will do what you're looking for.
>> eg:
>>
>> $children =
>> wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0&depth=1');
>>
>> --
>> Will Anderson
>> http://www.itsananderson.com/
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



-- 
Simon Wheatley
Sweet Interaction Ltd
Web Interaction Design & Development
Tel: 07971 687295

Consulting for Stephen Fry: http://stephenfry.com/
Blog functionality for DfID - http://blogs.dfid.gov.uk/
House of Illustration site - http://houseofillustration.org.uk/
Blog for the Royal Navy - http://jackspeak.royalnavy.mod.uk/

---
Sweet Interaction Ltd is Registered in England/Wales, no. 6610741
Registered office: 7 Malton Av, Manchester, M21 8AT


More information about the wp-hackers mailing list