WordPress.org

Ready to get started?Download WordPress

Forums

Dinstinguish first item from wp_list_pages() (3 posts)

  1. jesskahrawr
    Member
    Posted 7 years ago #

    I have put some effort into researching this topic before posting to ask for help but if I have overlooked something simple, please forgive me and point me in the right direction.

    I'm using the function wp_list_pages() to create a list for the header of my page and am using CSS to style the list elements with a background that creates a break between each of the items, by creating a line something like | in front of each item, this applies the style to all items. The problem is I don't want the same styling on the first item as there is no need for a break line at the start of the list. This is something that should be easy to handle in CSS using something like li:first but to my knowledge this hasn't been implemented across all browsers yet.

    My second best option would be to have a class applied to the first item of a list that could be used to apply a slightly different style (you could also add a class to the last item to generalise, but in my case I just need the first). I was consdering making changes to wp_list_pages() and implementing it as my own plug-in but it seems I would need to go much deeper to add the extra class. Before I plunge into that I'd like to request some advice.

    Is there another way I haven't found yet to do what it is I want to do? If adding a class to the first item seems reasonable, are there any plugins or examples out there already where people have done this, or something similar that I might find useful?

    If it all seems a bit messy there are a couple "work-arounds" (read: reconsidering the design) which may be the better option for now as I view this as a styling problem not particularly a code problem, but either way this still seems to be an issue that I think deserves an answer.

    Thanks in advance.

  2. ssdesign
    Member
    Posted 7 years ago #

    Hi,
    You might find this useful:

    http://www.liewcf.com/blog/archives/2005/05/wordpress-navigation-bar/

    Maybe you can look at the code and study it to find a solution to your problem.

    Hope that helps.

  3. jesskahrawr
    Member
    Posted 7 years ago #

    Thanks for the reply, it triggered a decision to go with an interim fix.

    A proper solution to this problem is a little beyond the scope I have right now. In the meantime I'll hardcode the first list item (to the homepage so I know it's not going anywhere) then list the rest, minus the page that has the hardcoded link (not a great solution but better then what we had before). Just telling people this incase they come up against the same brick wall and are wondering what the possiblities are.

    I'm still interested in a decent resolution if anyone has one.

Topic Closed

This topic has been closed to new replies.

About this Topic