Forums

ink_before and link_after not working with wp_list_pages (5 posts)

  1. leewilson78
    Member
    Posted 3 months ago #

    Hi all,

    I have successfully create a link pages using the following:

    <?php wp_list_pages('link_before=<b>&link_after=</b>&title_li='); ?>

    The wraps my title with <b>Tags</b>

    For some reason, the same method cannot be using for categories, i.e.

    <?php wp_list_categories('link_before=<b>&link_after</b>&title_li='); ?>

    I am a newbie when it comes to Wordpress, but CSS, HTML I am comfortable with. With this feature only recently being introduced, does this not yet work with categories, if so, is there a workaround?

    Thanks

  2. esmi
    Member
    Posted 3 months ago #

    There are no link_before or link_after parameters for wp_list_categories. If you styled your page links with CSS instead of using (deprecated) bold markup, you could also apply similar (if not identical) CSS to your category links.

  3. leewilson78
    Member
    Posted 3 months ago #

    I am trying to implement a menu here:

    http://www.cssmenus.co.uk/single.html

    The other option is to use a span, same problem though, how do we add text before and after. Can't figure out why it was added to the pages link but not the category.

    Any ideas.

    Thanks

  4. doodlebee
    Member
    Posted 3 months ago #

    I'm in need of the same thing. I'm trying to implement "sliding doors" to my category horizontal navigation - and span tags are needed before and after the text in the link.

    If I find a solution, I'll pots it - but hopefully someone else might have an idea. I'm thinking creating a custom array of some kind and injecting it into the walker Class might work - problem is, I'm not exactly sure how to do that ;)

  5. doodlebee
    Member
    Posted 3 months ago #

    Found it. There's a little preg_replace trick that pulls it off nicely.

    <?php echo preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i', '<li$1><a$2><span>$3</span></a>', wp_list_categories('echo=0')); ?>

    It as a little tricky for me at fist, because every place I found this, turned out the "curly quotes" were messing me up. Also, you MUST have "echo=0" in the wp_list_categories for this to work properly. Otherwise, it's worked a treat!

Reply

You must log in to post.

About this Topic

Tags

No tags yet.