WordPress.org

Ready to get started?Download WordPress

Forums

Show Proper Categories with nesting? (34 posts)

  1. gleem
    Member
    Posted 9 years ago #

    I don't understand why WP 1.5 lets you nest categories in parent categories, but then in the "categories" menu it displays them all inline, with no particular logic?

    Like if I make a category called "Pictures" and then a child category "Dogs" it should show this in the "categories" menu:

    Categories:
    --------------
    Category 1
    Category 2
    Category 3
    . . Category 3.1

    but instead it looks like this:
    Category 2
    Category 3.1
    Category 3
    Category 1

    you know what I mean?

  2. pezastic
    Member
    Posted 9 years ago #

    As to the styling problem, I know exactly what you mean. I am looking for a way to style each level differently in the stylesheet. I would like to have a different image background for each category level in the list. That is different from what you want. However, if someone can solve my problem, it will solve yours. If it is possible to style each level differently, you can place whatever indentation you want in the css.

  3. gleem
    Member
    Posted 9 years ago #

    exactly, why would they bother making "parent" and child categories if this feature wasn't built in? maybe it's just me or us, I dunno, seems silly.

  4. Lorelle
    Member
    Posted 9 years ago #

    I know these are a pain, but help is here. There is a very simple explanation of the nested lists in the Codex. In fact, there is a bunch and ever growing bunch of information related to styling with CSS in the Codex at http://codex.wordpress.org/Blog_Design_and_Layout that should also help.

  5. pezastic
    Member
    Posted 9 years ago #

    Lorelle, the styling solutions in that first link you presented is what I currently use. It works, but it is messy. I thought CSS was supposed to look cleaner than have a bunch of ul li ul li ul li selectors for a nested list. Isn't there a better solution?

    gleem, you also have a sort order problem, beyond the styling problem. Try <?php wp_list_cats('optionall=0&sort_column=name'); ?> to get the right sort order.

  6. gleem
    Member
    Posted 9 years ago #

    gonna read that link 5 more times before I call it a day. Wow, was hoping for something simpler, and call me a newb (I'm not) but that's seems overly complicated for a simple thing.

    thanx for the link though, I'll eventually figure it out

  7. Lorelle
    Member
    Posted 9 years ago #

    And the problem might not be WordPress, and in fact, probably isn't. Have you checked the CSS related to your list? The way the list looks is controlled by the CSS.

    If the margins are set to zero, then they will line up like that. If they are set to ul ul {margin-left: 10px} you will suddenly find them indented. If not, try ul ul ul to make sure they aren't in nested template tags.

    Some of the tags for listing Pages and Categories, etc., are set to be used like:

    <ul>
    <?php TEMPLATE TAG; ?>
    </ul>

    And others are set to be:

    <?php TEMPLATE TAG; ?>

    With the UL included in the Tag parameters. So you might have to experiment. I usually color the font differently for the different nested items in the CSS and then see what turns what color and then fix the line up and remove the rainbow color references.

    This makes sense for those who don't want to mess with the layout, but it can wreck havoc with those who want to dig into the code.

  8. Lorelle
    Member
    Posted 9 years ago #

    <?php wp_list_cats('optionall=0&sort_column=name'); ?>

    Took me a bit, but it makes sense.

    List categories
    Do you want to list all of them - 0=YES (1=NO)
    How do you want to sort them? By name or ID - choice=name

    See, it makes sense if you just ignore the ampersands.

    And it is much more helpful than the construct for this tag:

    <?php list_cats(FALSE, '', 'ID',
    'asc', '', TRUE, FALSE,
    FALSE, FALSE, TRUE,
    FALSE, FALSE, '', FALSE,
    '', '', '1,33,43,61,74,101,456',
    TRUE); ?>

    That one will have even the bravest up at night trying to figure out. It's right out of my site!

  9. gleem
    Member
    Posted 9 years ago #

    pezastic, I Don't see how categories have any clue in what way they are to be ordered except by their ID, which I Suspect is the main problem of the side menu deal.

    I mean, we can order links, but not categories? Surely categories are more important in a site of content.. no?

    peza, I assume by my little knowledge of PHP that your little plug there just orders em alphabetically?

  10. gleem
    Member
    Posted 9 years ago #

    Lorelle, you're right, except all my categories, sub cats or not just get spit out as "li" , did I miss a way to tell the script to pop em out as a different class or something?

  11. Lorelle
    Member
    Posted 9 years ago #

    http://codex.wordpress.org/Template_Tags/list_cats
    http://codex.wordpress.org/Template_Tags/wp_list_cats

    This is how.

    And this is where you learn how to make the choice to either have them in LI lists or not.

    If you have them in UL/LI lists, you have more control over how they look. If you don't, then they will just sit there, all even with the left margin.

  12. gleem
    Member
    Posted 9 years ago #

    What I would really like is a way to manually order them, is there a way to manually type in the category order in the php file?

  13. Lorelle
    Member
    Posted 9 years ago #

    Did you click on the links I just gave you? They tell you, step by step, how to do this. Check out the http://codex.wordpress.org/Template_Tags page for more information on other parts of your lists. And read through the http://codex.wordpress.org/Styling_lists_with_CSS article on the Codex that will explain EVERYTHING to you in graphic detail. I helped write it, so I know that it has all the answers.

  14. gleem
    Member
    Posted 9 years ago #

    LOL, sorry man I didn't see it, I still have to read it 3 more times to digest it.

  15. gleem
    Member
    Posted 9 years ago #

    k, read all the sections under the "Category Tags" and didn't see any of them that said something along these lines:

    "To display a specific category ID use this:"

    maybe we are misunderstanding eachother, this is what I need to do in my sidebar:

    a version of this tag: <?php wp_list_cats(); ?> that would only display one of my categories by id, so I can do this:

    <?php show category ID=7; ?>
    <?php show category ID=1; ?>
    <?php show category ID=5; ?>

    because I want to list em in my order, not alphabetical or in numerical ID order.

    If I missed how to do this in thatr template tags page, I guess I am a tard :)

  16. Lorelle
    Member
    Posted 9 years ago #

    If you had read the specific tags I pointed you to, you would have found this example:

    <ul>
    <?php wp_list_cats('sort_column=name&optioncount=1&exclude=10, 15'); ?>
    </ul>

    It says, list the categories sorted alphabetically by name (not ID), show the number of the posts within each category (shown as (3) after the category - if you want it), and then exclude categories 10 and 15. This is if you don't want the specific categories.

    If you are not excluding any, then use:

    <ul>
    <?php wp_list_cats('sort_column=name&optioncount=1'); ?>
    </ul>

    If you don't want the list in alphabetical order by name, or sorted by ID, then you have a more complicated problem. If your blog is totally new, this isn't a stressor. If it isn't and filled with tons of old posts all in dozens of categories, cry with me.

    Okay, so if it is new, then simply go to your Admin screen MANAGE > Categories and delete them all and start over, entering them in the specific order you want them to appear. Now, there is a trick to this. I can't remember right now, but if you do this, they should be removed from the database and the new ones should start with ID numbers of 1, 2, 3. But it might not happen because the database needs to have the ID numbers of the categories be unique, so it might start numbering them 6, 7, 8, but either way, they will be in a numbered sequence so that category 1, would be 6, category 2 would be 7, and so on.

    Does that help?

  17. gleem
    Member
    Posted 9 years ago #

    yeah, I read that line, I didn't think it was a solution cause:

    <?php wp_list_cats(exclude=2, 3, 4, 5, 6, 7, 8, 9, 10'); ?>

    if I wanted to only show category id1 in my sidebar, so to make a complete list in my order I would simply have to tell it to exclude every number besides the one I wanted to display. Somehow I think that might much things up though since I'd have to make 10 of those lines to get 10 cat id's out there?

    oh and it is new ;)

  18. gleem
    Member
    Posted 9 years ago #

    oh, and redoing them that way (category delete, reenter) would work till I needed to add a new catgory down the road that I Wanted higher up in the list than the very bottom.

  19. gleem
    Member
    Posted 9 years ago #

    *bump for the morning crew*

  20. pezastic
    Member
    Posted 9 years ago #

    From Podz on an unrelated thread:

    "Try adding spaces to their names.
    A category with a space before it's name will display above a category without a space.
    The space is not shown when displayed on your blog.
    This way, you should be able to determine display order."

    Alternatively, I think you're going to have to re-order the MySQL database with something like phpMyAdmin.

    I'm still re-reading the first codex link presented here for a possible solution to my problem. There's a lot to digest in that reference.

  21. moshu
    Member
    Posted 9 years ago #

    Pezastic, I think the space solution was working only in pre-1.5. versions.

    Lorelle, the problem is, no matter what the Codex says...
    for the sub-Pages WP puts around them another <ul><li> tag - so I can style them correctly (indent etc.), but for the sub-category doesn't.
    In some earlier (beta?) versions there was an additional <ul class="cildren"><li> tag around the children (=sub) categories, but in my 1.5, called "latest" on the download page, whatever I do with the list_cats or wp_list_cats it will not put any additional ul and li around them.

  22. gleem
    Member
    Posted 9 years ago #

    yeah, spacing doesn't work.

    back to the drawing board *bangs head on wall*

  23. Lorelle
    Member
    Posted 9 years ago #

    Just to let you know, my "exclude categories" list had over 30 numbers in it. I've asked the developers to add an "include" reference in the next version.

  24. gleem
    Member
    Posted 9 years ago #

    that would be nice ehh?

    I'm contacting some programmers to see how much it will cost for them to build me a plugin to do this, maybe I'll share it ;)

  25. Root
    Member
    Posted 9 years ago #

    And maybe I am therefore right in saying ? that the style comp is being hosted ona beta version of 1.5 ? Because there is no doubt that the mark up being delivered by the php is different in the final as moshu points out.. So the CSS ul.children does not take effect. In short - a bork. :)

  26. gleem
    Member
    Posted 9 years ago #

    you lost me dude, was that haxor speak or something?

  27. pericat
    Member
    Posted 9 years ago #

    gleem, I've written a plugin that may be what you want. Explicit Category Sort. Download: http://pericat.ca/downloads/perisort.tar.gz

  28. gleem
    Member
    Posted 9 years ago #

    HOLY CRAP PERICAT!!! that's exacto-freaking-ky what I've been looking for!!!!

    THANX!!!

  29. pericat
    Member
    Posted 9 years ago #

    Cool!

  30. pezastic
    Member
    Posted 9 years ago #

    You know, I didn't even want something like that until I read this thread. Now, I think I want to use it, too! You're awesome, pericat!

    BTW, I'm still trying to absorb the info in that first link. The problem I am having is styling a category list. Not just any category list, but one where there are subs and sub-subs and the post numbers are after each category. What I want is a different background image and hover image on each level, with a block display.

    I can do that on a normal list, but I don't know what to do when the post count is there, as the post count is not part of the category link. What is happening is that the post count is displaying outside of the styling, on a line beneath each link all by itself.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.