[wp-hackers] Multi-level page nav

Shane A. Froebel shane at bugssite.org
Sun Aug 2 13:41:52 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I just thought I share what I have:

<?php

$children =
wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");	

if ($children) {
	
?>

<div class="module">
	<div class="module-head">
		<div align="center"><h3><?php _e('Sub Pages'); ?></h3></div>
	</div>
	<div class="wrap">
		<div class="content">
			<ul class="dash-strip">
				<?php echo $children; ?>
			</ul>
		</div>
	</div>
	<div class="module-footer">
		<div>&nbsp;</div>
	</div>
</div>

<?php } ?>

I have an "About" page that is the top level page. Under that I have
"'History of ‘the rabbit hole’". Under "History of ‘the rabbit hole’" my
"WordPress Plugins" page shows up under 'Sub Pages', but my "About" tab
(at the top of the site, finally goes 'Inactive css class' once I goto
the "WordPress plugins" page since the parent page "History of 'the
rabbit hole'" is now not listed.

But this seems to work for me. I really should be doing 'if
(!empty($childern)'. Might change that now..

Your Friend,
Shane


Simon Wheatley wrote:
> 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
>>
> 
> 
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)

iQIcBAEBAgAGBQJKdZefAAoJEC7/vS6gbNwFzZAP/A5aasv8prNNHKvNlK0b0S9a
+RPNI0K90/JTHWXy3eJXeNMki7kgYbQsWjHt7froFpxn0m+T+mh01nq8EYNbo2zk
KZilu01KOPHCKIFIV8TNToEsIQrB5W1uzMDN9uqTAOxwG/HgxMq2j5AvrixTYWmH
rZ0Acre00jdIzXNj7SaNBSpDstN+O3ImCQmzqA+7HkR2V2aB+qBvd+RnMhkfyZYG
tqntw5uD5IAVO/m0svafdmpi+0fELRxl+dAKKIU5zKBYm3pj4GaTiggv9iXhMBZi
EnaZratZKI0KgQhu1CUVv/JJfwvqw8lbUI63qE9DDqWxJWu8M3Qp/KYJM+nIBq80
PI2oLoEvtjb59OQY4yHxLTnJfYOtmnTjCtC4XNbe/y+XKHm696cY+XDx6kDsfBPn
OeSqye1oo1zyRXUfhHCk1VPevB6ZvX8vC9TTThQgAnWWjdumhQ/91KwjZsjTyMtk
xqWnhzwfGRvInUXn1k1Q7k/tzx6B9z5NIlQyTjbjoCc0N3+7s+3ChSVsOedLCKRl
9OoyTc9SaT70NfV7nzGS2WVpvMpOZ8FzoXLTqVWg/YxKjkEmhqwA6JHAwMoRerQE
lF4Fma+aaTdTjYdCQ3kOloytU/9cvwobD99OWmvvtlOg94MZ4EUN0n1bTVVjLSc7
D/k9Dn+qeggKtKr7FSuo
=r3x2
-----END PGP SIGNATURE-----


More information about the wp-hackers mailing list