WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Style just one element in wp_list_pages() differently?

[Resolved] Style just one element in wp_list_pages() differently?

  • Matt

    @intellivision

    I need to single out and style differently a single parent

  • element in wp_list_pages’s output.
  • Any thoughts?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Matt

    @intellivision

    Anyone? Bueller? Bueller?

    in those 19 hours you could have hit ‘view/source’ in your browser and seen:

    <li class="page_item page-item-27054">
       <a href="http://dencx.com/?page_id=27054" title="Blingo">Blingo</a>
    </li>
    <li class="page_item page-item-27012">
       <a href="http://dencx.com/?page_id=27012" title="Friends">Friends</a>
    </li>
    <li class="page_item page-item-27004">
       <a href="http://dencx.com/?page_id=27004" title="About">About</a>
    </li>
    <li class="page_item page-item-27019">
       <a href="http://dencx.com/?page_id=27019" title="Contact">Contact</a>
    </li>

    See how each of them has two classes specified?

    you can style either .page_item, or more specifically, .page-item-27004

    Matt

    @intellivision

    Well it’s funny you should bring up those 19 hours, because in them I put a

    .page_item page-item-3 {
    	border-right: none;
    }

    in my style.css, but it didn’t work. I’m looking for explicit instruction, that’s why I posted here.

    well, use one of the classes not both… page_item and page-item-3 are two different classes.

    .page-item-3 {
    	border-right: none;
    }
    Matt

    @intellivision

    …and the winner is

    li.page-item-3 a {
     border-right: none;
    }

    This works great if you’ll always have the same number of pages and never will add any… but what if I add a page later that ends up at the right-end of the list and I want THAT one to be styled uniquely (ie- no border on the right side)? Is there a way to do this with some fancy PHP code to count through and only add the class name in if it’s the last item?

    THANK YOU mutedgirl!!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] Style just one element in wp_list_pages() differently?’ is closed to new replies.
Skip to toolbar