WordPress.org

Ready to get started?Download WordPress

Forums

Cat's as headings, sub-cat's as links? (4 posts)

  1. tcervo
    Member
    Posted 10 years ago #

    Using the 1.1 nightly, is it possible to have categories show up as headings, with the associated sub-categories listed underneath? For example, I have a Category of "Difficulty", with the following Sub-Categories: "easy", "medium", "difficult". So, I'd want my category listing to be:
    Difficulty
    easy (1)
    medium (3)
    difficult (1)
    Same thing for other cats/sub-cats. I always want to assign a post to one or more sub-categories, and never assign to a category directly...The way I envision it is kinda like link categories, with the sub-categories being the links....
    Does that make sense, and if so, any ideas? Otherwise, I don't really see the usefulness of sub-categories.
    Thanks,
    Tony

  2. TechGnome
    Moderator
    Posted 10 years ago #

    the List_cats function takes a lot more parameters than indicated in the defauly index.php. Here's the one I use and it gives the result you want. The key is the last parameter.... by default it is set to false. Set it to TRUE and it will indent sub cats.
    <?php list_cats(0, 'All', 'name','','',TRUE, FALSE, FALSE, FALSE, FALSE, TRUE); ?>
    I then added the following to get it to match the rest of my menu.
    #menu ul ul ul.children {
    padding-left: 4px;
    font-size: 142%;
    }
    TG

  3. tcervo
    Member
    Posted 10 years ago #

    TG,
    Thanks...that's getting closer. One problem now, though, is that empty categories (and sub-categories) are showing, which I don't want. One solution would be to only ad a category or sub-category when I'm ready to add a post in that cat.
    The other problem is that categories are showing up as links, which I don't want since I'm never going to post in them. I wish there was a way to have this work like link categories...the category titles show up as headings (well, sort of...at least they're not clickable), with the sub-categories as links underneath...
    Oh well, I'll tinker around and see if I can't get the categories to not display as links.
    Thanks,
    Tony

  4. tcervo
    Member
    Posted 10 years ago #

    Ok, nevermind the problem with empty categories showing up. At first, when I changed the third from last parameter to true, I got "no categories". When I tried, just for kicks, associated the post with the parent category *and* the sub-category, and making sure the third from last parameter in list_cats is true, I get just the cat/sub-cats that have posts.
    I still don't want the category to be a link, but I can live with it for now.
    -Tony

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.