1

Is it possible to have Wordpress generate this type of unordered list?

<ul id="nav1">
<li><a href="#">item1</a></li>
<li><a href="#">item2</a>
<ul id="nav2">
<li><a href="#">subitem1</a></li>
</ul></li>
<li><a href="#">item3</a></li>
</ul>

Obviously I can do the following:

<ul id="nav1">
<?php wp_list_pages(); ?>
</ul>

But my question is, how do I make it so that I can have a secondary ul under a page (or list item such as 'item2' above)?

Basically, I'm looking for a way for Wordpress to dynamically generate the following:

<li><a href="#">item2</a>
<ul>
<li><a href="#">subitem1</a></li>
</ul></li>

And I can use JQuery if necessary to give the secondary (sub menu) unordered list an id of #nav2...

Anyway, is this possible?

Thanks and I appreciate all of your help!

Amit

2 Answers 2

1

Nevermind guys.

I just tried it with the wp_list_page(); function and it works. It does exactly as I wanted it to with exception to one thing...

It put's an extra <ul> in there so the list looks something like this:

<ul id="nav1">
Pages
<ul>
<li><a href="#">item1</a>
<ul class="children">
<li><a href="#">sub-item1</a></li>
</ul></li>
</ul>
</ul>

Anyone know how to get rid of the <ul> following the Pages title, as well as NOT show the word Pages?

Thanks, Amit

Sign up to request clarification or add additional context in comments.

1 Comment

Finally, the answer is with 'title_li=', that gets rid of the Pages and extra ul tag :)
1

Okay, I solved the added ul program.

This is what I have as the result:

<ul id="nav1"><?php
                $pageargs = array(
                    'link_after'  => '&nbsp;/',
                    'title_li'     => __('')
                    ); 
                wp_list_pages($pageargs); ?></ul>

Hope someone benefits from it :) Amit

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.