WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Style just one element in wp_list_pages() differently? (10 posts)

  1. Matt
    Member
    Posted 6 years ago #

    I need to single out and style differently a single parent

  2. element in wp_list_pages's output.

    Any thoughts?

  • Matt
    Member
    Posted 6 years ago #

    Anyone? Bueller? Bueller?

  • Ivovic
    Member
    Posted 6 years ago #

    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
    Member
    Posted 6 years ago #

    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.

  • Ivovic
    Member
    Posted 6 years ago #

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

  • iridiax
    Member
    Posted 6 years ago #

    .page-item-3 {
    	border-right: none;
    }
  • Matt
    Member
    Posted 6 years ago #

    ...and the winner is

    li.page-item-3 a {
     border-right: none;
    }
  • mutedgirl
    Member
    Posted 6 years ago #

    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?

  • mutedgirl
    Member
    Posted 6 years ago #

  • kristanlh
    Member
    Posted 6 years ago #

    THANK YOU mutedgirl!!

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags