Support » Fixing WordPress » wp_list_categories: How to get the tag outside of tag

  • I am creating a list of categories…


    [please mark even the smallest snipppets of code such as single <li> – see ]

    The problem is, I have an icon in the background of my <li> tags. In order to make the “icons” clickable, the link <a> tag needs to be OUTSIDE of the <li> tag.

    So, instead of…

    <li><a href="">Category</a></li>

    I need….

    <a href=""><li>Category</li></a>

    How do I do this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael


    Forum Moderator

    your attempted code would be invalid html –

    it might be better if you can describe why you assume you need the change, or what you are trying to achieve.

    The code works on my page. The output of wp_list_categories is an itemized list of categories with the link INSIDE the list tag.

    I need the take the link outside of the list tag, and surround it around the list tag. I do this in straight HTML on another list and it works fine.

    And technically, the code isn’t invalid. Just not commonly used that way. If I just link the text

    <li><a href="">Category</a></li>

    Then the background image style of the li tag wont be a link. There is an icon in the background of the li tag, so it looks like an icon and then the text. With the code above, the icon isn’t clickable.

    With the code below, the icon AND the text would be clickable.

    <a href=""><li>Category</li></a>

    Is there a way to wp_list_categories WITHOUT it outputting the ‘li’ or the ‘a’ tag? Then I can add the link AND the list tag in html, and not have it automatically throw it in.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_list_categories: How to get the tag outside of tag’ is closed to new replies.