WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Separating wp_list_pages with a / (6 posts)

  1. cboakes
    Member
    Posted 4 years ago #

    Hi there,

    What is the best way to separate page headers with the '/' symbol?
    Currently I am just using:
    wp_list_pages('title_li=0&sort_column=menu_order');
    to display the page titles.

    Any help would be greatly appreciated,

    Thanks

    Chris

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    You don't have to separate the links with anything. They're already in an unordered list. If you want to separate them, you could use CSS to add a graphical list bullet that would act as a separator or you could add a left or right border - again using CSS.

  3. cboakes
    Member
    Posted 4 years ago #

    Thanks esmi,

    I managed to figure out by simply looking up the 'wp_list_pages' in the codex, there I was able to find that there is in fact a parameter that can be passed called 'link_after', which does what I want. So to display a / character after each link I would simply just pass the parameter like this:

    wp_list_pages('title_li=0&sort_column=menu_order&link_after= /');

    Chris

  4. Mark / t31os
    Moderator
    Posted 4 years ago #

    You'll of course have a / after every link including the last.. if that works with what you have fine, else you'd just need to return the data and do a little PHP magic to not show the / when printing the last item.

  5. cboakes
    Member
    Posted 4 years ago #

    I did notice that - it is an issue that I'm going to try and solve.

    What do you think would be the best way to approach it?

    Thanks

  6. Mark / t31os
    Moderator
    Posted 4 years ago #

    After looking at this more in-depth i realise that using echo=0 with wp_list_pages is pretty useless..

    You don't get an array of the results, you get one long string... which is pretty useless without some regex to move things around, but that's a really horrible way to manage the results.

    Other functions give you the items as an array with the echo parameter set to 0 (off), but wp_list_pages seems to be an exception in this case..

    Such a shame... because the only solution i can see for dealing with this is to use various lines of regex, which would get very messy very quickly...

Topic Closed

This topic has been closed to new replies.

About this Topic