WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i'm using wp_nav_menu to generate a navigation menu for my theme. It works fine by selecting my created menus. But, what if i want to generate a list from my already created pages and subpages in wordpress ? I tried using wp_page_menu, which does what i want, but i cannot pass a css class parameter to the inside ul, in order to stylize my menu.

Does anyone know how i can do that ?

share|improve this question
Are there sub-sub-pages (i.e. up to what depth does it need to work?)? Do several pages have children or is there but one with sub-pages? If there are more than one, is it satisfactory if all inside <ul> elements have the same class? – Johannes Pille Nov 14 '11 at 7:24
It's just enough if only the outer ul has a class specification :) – SpyrosP Nov 14 '11 at 7:30
up vote 2 down vote accepted

I faced that problem in the past, however I remember my problem was the first link didn't have a class, after some research I solved it working with a structure similar to this one, take a look and let me know if it works :)

   <?php wp_list_pages('title_li='); ?>


share|improve this answer
Hey, thank you for the reply :) It actually does not work and the reason is that wp_list_pages already creates an inner <ul> that messes with the external <ul> that you specify. What i would want to do is set the class name for the internal <ul> produced by wp_list_pages. – SpyrosP Nov 14 '11 at 7:12
@SpyrosP While Andrew's "first link" issue has nothing in common with your problem whatsoever, wp_list_pages() is a solution to it. When called with an empty title_li= parameter (as he does above), the list the function does generate will not be wrapped in <ul></ul>. Hence you can define classes for the outer <ul> using regular markup. – Johannes Pille Nov 14 '11 at 7:45
Actually that is what I was meaning, my problem was not exactly the same, however the title_li= empty basically do not wrap the into the <ul> </ul>, I just copy and paste the code I used. My bad for do not explain myself better. @SpyrosP did you check the output it generates? – andresmijares25 Nov 14 '11 at 8:46
Yeap, thanx for the clarification, that's exactly what i wanted :) – SpyrosP Nov 14 '11 at 18:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.