WordPress.org

Ready to get started?Download WordPress

Forums

wp_list_categories: How to get the tag outside of tag (5 posts)

  1. jabbamonkey
    Member
    Posted 2 years ago #

    I am creating a list of categories...

    <?php
    wp_list_categories('orderby=id&show_count=0&child_of='.$parentcat->cat_ID);
    ?>

    [please mark even the smallest snipppets of code such as single <li> - see http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

    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?

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    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.

  3. jabbamonkey
    Member
    Posted 2 years ago #

    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.

  4. jabbamonkey
    Member
    Posted 2 years ago #

    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.

  5. esmi
    Forum Moderator
    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic