WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Why do child cats use the same class as threaded comment replies (11 posts)

  1. delevega
    Member
    Posted 8 months ago #

    I am hoping a member of the WP team can explain why this is set up this way.

    I do not use child categories at all, but in order to test a theme I imported the WP test data. As many might know, there are child categories in this test data.

    When using the categories widget built into WP child categories are simply surrounded by

    <li></li>

    like all of the rest of the category items. However, when using wp_list_categories() in a sidebar child categories are set up as an unordered list that looks like this.

    <ul class="children">
    <li class="cat-item"></li>
    </ul>

    The first inconvenience is that this class uses the same name as the class used in the threaded comments. If you want to style what a nested comment level looks like you use .children. So what you apply to this style could easily effect both of the comments and the categories. (Yes this can be worked around by targeting your css, which is why I simply called it an inconvenience.

    Then a second inconvenience is that now we have to write extra css to handle the ul ul and li li that effects the child category. Which can also be worked around. But what if you are using em font sizes, there is a good chance that the child category will have a smaller font size rendered than the other category items.

    Why aren't child categories simply surrouned by <li></li> and given a unique class name in case someone does want to style it differently?

    Could someone informed please tell me if these are over sights, or done for specific reasons? If so what are the reasons, and why does the category widget display differently than the wp_list_categories() function?

    Looking over the wp_list_categoires() function is in wp-includes/category-template.php it doesn't seem like a hard thing to change. Will this be changed in any future WP releases?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    So what you apply to this style effects both the comments and the categories.

    No you don't. Try targeting your CSS rules more specifically. There's a world of difference between .cat-item .children and .comment .children.

  3. delevega
    Member
    Posted 8 months ago #

    I understand what you mean, Esmi. I'm just saying it is an inconvenience, and asking why they use the same name? I do target mine differently, and get the results I want. (If you notice I did say this coud be worked around by targeting css.) I am just wondering why the widget handles them one way while the function handles them another? What is the reasoning to give child categories their own unordered list? (Thank you by the way if you are the one who fixed my post where I wrote out the list item code and it rendered it by mistake. Appreciate that.)

  4. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    Please see above. I've added some examples.

  5. delevega
    Member
    Posted 8 months ago #

    I understand completely, Esmi. I am targeting my css like that in case one day I do need a child cat. I am just wondering why the widget handles it by just making it a normal list item where as the wp_list_categories function gives it its own unordered list? Couldn't the same effect be achieved by just making child cats a list item with a unique class name?

  6. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    Why aren't child categories simply surrouned by

  7. and given a unique class name in case someone does want to style it differently?

    I'm not sure I understand what the issue is here.

  8. delevega
    Member
    Posted 8 months ago #

    it's not an issue or complaint. I am simply curious why the WP team decided to place child categories in their own unordered list instead of just doing something like?

    li class="child-cat-item"

    And why isn't this done in the widget as well? Just curiosity, which is why i posted in the feedback section.

  9. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    I am just wondering why the widget handles it by just making it a normal list item

    Actually the output of any widget classes are controlled by the current theme. See http://codex.wordpress.org/Function_Reference/register_sidebar

    [Sorry - we seem to be cross-posting a lot :-) ]

  10. delevega
    Member
    Posted 8 months ago #

    All right, I never knew that they were controlled by theme. That is actually a pretty neat way of doing it.So one theme using the category widget can treat child cats as a normal list item where some themes using he widget can treat child cats as an unordered list?(Sorry for the cross posting as well.)

    Can this be done with wp_list_categories function?

    --
    After reading over our posts I think I may have misunderstood. I have checked several themes, and the category widget always treats child cats as a normal list item.

    The way I understood what you said is that a theme can determine how the html is set up for the category widget. Is this what you meant?

    --
    Okay!! I've got it now. (please disregard anything written above this.) The classes to be assigned to the widgets can be customized. I never ever knew that! Way cool!

    But last question, can the wp_list_categories function be set up not to place child cats in an unordered list without editing core code?(Which I would never do.) I still do not understand the need for a child cat to be in a second ul though.

  11. delevega
    Member
    Posted 8 months ago #

    [Moderator note: It's not a bump if you're contributing towards your issue]

    I absolutely hate to bump my own post, but I kind of thought up a better way specify what and why i am asking.

    The wp_list_categories html with a child cat looks something like this

    <ul>
      <li class="cat-item">cat 1</li>
      <li class="cat-item">cat 2</li>
        <ul class="children">
          <li class="cat-item">cat 2 child</li>
        </ul>
    </ul>

    So say your sidebar looks like this. (over simplified example)

    <div id="sidebar">
    <ul>
      <li class="cat-item">cat 1</li>
      <li class="cat-item">cat 2</li>
        <ul class="children">
          <li class="cat-item">cat 2 child</li>
        </ul>
    </ul>
    </div>

    Say you have a font size of .95 assigned to #sidebar ul li. Wouldn't the font in children render smaller than the other fonts, and require further CSS to fix this issue?

    I am simply asking why the child cats are in their own ul because all it does is add more CSS to write, and it doesn't really do anything semantically. It just makes more CSS to target and write really.

    The category widget does their list like this.

    <ul>
      <li class="cat-item">cat 1</li>
      <li class="cat-item">cat 2</li>
      <li class="cat-item">cat 2 child</li>
    </ul>

    I understand this may be knit-picky or annoying from a WP developer stand point. Although I am really curious why they chose to do it one way for the widget and one way for the function?

    Why not just meet in the middle and do something like

    <li class="child-cat-item"></li>
  12. delevega
    Member
    Posted 8 months ago #

    To anyone else that reads this, after some research it turns out that the method of two unordered lists actually solves several issues.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.