• I’ve read a lot of posts here in support for people wanting to use wp_list_pages to change navigation or styling for the list when you’re on a particular page.

    My problem is different, I would like to create a conditional statement that I can use to style the background color differently for pages I designate. So (in plain English) if post = 25 then make the li element background for post 25 “grey”.

    In the elements that wp_list_pages brings page you get first the ul, and then the individual li’s like this:

    <li class=”page_item page-item-25″>

    I want edit my stylesheet to make the background for “page-item-25-grey” which is easy enough, but what if I want to make all it’s children grey background too (and don’t want to edit the css everytime I add a child page)?

    Is this a CSS hack, or a conditional php statement I can add to wp_list_pages?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Not quite sure I’ve followed what you want, but this in your style.css theme file might do it:

    li.page-item-25, li.page-item-25 li { background: grey; }

    Or have I misunderstood?

    – Tim

    Thread Starter jtpratt

    (@jtpratt)

    Tim- thanks for the help. I had wanted PHP code to do it with wp_list_pages so I wouldn’t have to hardcode the page-item-number into css after pages were created (but that does work).

    thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_list_pages unusual conditional statement help’ is closed to new replies.