Public Voice Network
- Shit QBNers Say 128128
- Multicolored logos? 1111
- blog 5558055580
- Light in the Box Coupons
- Vid of the Day 1096110961
- TYPO San Francisco 55
- Suggest a good movie... 936936
- Logo from Locked PDF? 33
- American Musical Supply C… 11
- Pic of the Day 5937359373
- FMT 020312 4646
- intern -> job 2121
- Your Last Concert 375375
- the gif animation thread 1132211322
- Steve Jobs FBI file 66
- Shit QBNers think 6969
- What are you listening to… 41734173
- Park Slope 22
- The Elder Scrolls V: Skyr… 7676
- ♥ Things girls like ♥ 9696
- AE shadows won't work 99
- Politics 1759717597
- Chick of the Day 1431414314
- Skateboarding. 598598
WP nav question 1111 Responses
Last post: 2 years, 3 months ago | Thread started: Oct 16, 09, 8:29 a.m.
- jamble
This has me slightly stumped and the wordpress forums are shit.
Anyone know how I can modify the standard WP nav:
<?php wp_list_pages('sort_column=menu_order&title_li=&depth=2'); ?>
So that it outputs a class on any sub pages?
At the moment I get this:
<ul id="nav">
<li><ah href="#">Link</a></li>
<li><ah href="#">Link</a>
<ul>
<li><ah href="#">Link</a></li>
</ul>
</li>
<li><ah href="#">Link</a></li>
</ul>I just want to add a class of subnav to the second level ul but I'm fucked if I can find out how to do it. Any ideas folks?
Cheers,
- Oct 16, 09, 8:29 a.m. – Permalink
- taxiguerrilla
Why don't you simply handle it with css?
#nav > ul > li { /* level 1 menu definition */ }
#nav > ul >li > ul > li { /* level 2 menu definition */ }

- Dog-earOct 16, 09, 8:31 a.m. – Permalink
- taxiguerrilla
Ah, ok, and you can't select objects with jQuery the same way?
Anyway, I can't find it now, but there is a way to obtain the list of pages / subpages using a while {} loop. I'll make a search on my HD, if I find it I'll write you the snippet.


- Dog-earOct 16, 09, 8:35 a.m. – Permalink
- taxiguerrilla
Didn't find it on my HD, but found something that could help you:
http://stackoverflow.com/questio…
I think this way you should be able to nest 2 or more loops.


- Dog-earOct 16, 09, 8:40 a.m. – Permalink
- acescence
a couple options, you can go into includes/post-template.php and edit the actual function. of course this will break if you upgrade. another option is to use a filter hook to process the output of wp_list_pages before it gets output to the template. another option is to copy the entire function and paste it in your template's functions.php file, then give it a unique name and edit the html it outputs.


- Dog-earOct 16, 09, 9:21 a.m. – Permalink
- bulletfactory
sometimes it's easier to do a hybrid of hardcode/dynamic.... example:
<?php if (is_page('About') || is_page('Contact')) { ?>
<ul class="subnav">
<li><a href="<?php echo bloginfo('url'); ?>/whatever.pdf" title="link">link</a></li>
</ul>
<?php } ?>hope that helps.... and was what you were asking.

- Dog-earOct 16, 09, 9:25 a.m. – Permalink
- jamble
Cheers folks,
I can't really hardcode the nav as the pages will be updated/added to over time so the nav will grow / change a bit and I don't want the maintenence job.
@Stugoo, I might be making a total balls of a simple job but I can't for the life of me get this (http://www.noupe.com/tutorial/d... dropdown nav to work because the .subnav class in the jQuery doesn't exist when WP generates the menu in the format in my original post.
Sorry if it's not hugely clear,I'm developing locally so I don't have a link to show at the moment.


- Dog-earOct 16, 09, 9:30 a.m. – Permalink
- bulletfactory
note: i only meant to hardcode the <ul class="subnav"> and let the list items inside it be dynamic.
it could grow as large as you want and be fine.

- Dog-earOct 16, 09, 9:33 a.m. – Permalink


