• 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

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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.

    Thread Starter leewilson78

    (@leewilson78)

    I am trying to implement a menu here:

    https://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

    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 ??

    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!

    Hi. I’m trying to do it too, but i’m not having success. anyone can help me?

    <?php
      $categories = get_categories();
      $output = '<ul id="menu">';
      foreach($categories as $category){
          $output .= '<li class="first" id="home"><a href="'.get_category_link( $category->term_id ).'" linkindex="0"><b>'.$category->name.'</b></a></li>';
      }
    $output .= '</ul>';
    ?>

    Try this type of code once.

    I am also trying to find a solution for this…

    Can anyone explain how it works aswell as supplying code?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘ink_before and link_after not working with wp_list_pages’ is closed to new replies.