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 ?

  • 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

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='); ?>


  • 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? – andresmijares 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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