WordPress.org

Ready to get started?Download WordPress

Ideas

Category Templates

  1. João Sardinha
    Member

    I find my self many times adding something like this to my category.php files
    if (is_category($id)) { //load custom loop } else { //normal category loop }

    And i dont really like it, it feels too hard coded and is a pain when going multilanguage, it would be nice to have the option to choose a template for a category like the function already implemented for pages, it could look like this

    <?php
    /*
    Category Template: Block Items
    */
    ?>

    This would be great in my point of view, and i think lots of people would like, it would really give room to developers to be more creative with their themes.

    Please discuss this idea.

    Posted: 2 years ago #
  2. Ipstenu (Mika Epstein)
    Half-Elf Support Rogue & Mod

    it would be nice to have the option to choose a template for a category like the function already implemented for page

    There's already a built in feature for that.

    http://codex.wordpress.org/Template_Hierarchy#Category_display

    Posted: 2 years ago #
  3. Justin Tadlock
    Member

    12345

    Until there's a term meta table, I don't see this happening. WP needs a way to easily save the data (template name).

    I'm giving this a three-star rating because I don't think this necessarily needs to be built into core. I'd like to see the term meta table for plugin/theme devs to take advantage of though.

    There's already a built in feature for that.

    That's true only if you know the exact slug/ID of the category. As a theme developer, it's impossible to know that when you're building public-release themes.

    Another "feature" is that you could use a single template for multiple categories rather than re-copying the same template over and over, then renaming it.

    Posted: 2 years ago #
  4. I am aware of the current options, and the example i gave was because i was targeting multiple categories today and i i remembered that example, there was no need to create 3 files that were the exact same thing.

    The current method only works if you know the id/slug, which as mentioned is impossible to know if you're building a public-release theme, it would be great if the user could choose, let's hope one day the feature is implemented

    Posted: 2 years ago #
  5. Ipstenu (Mika Epstein)
    Half-Elf Support Rogue & Mod

    That's true only if you know the exact slug/ID of the category. As a theme developer, it's impossible to know that when you're building public-release themes.

    Oh true, but in the example he was mentioning using the ID anyway, so I presumed this was for child themes/personal use. For public themes, you'd have to handle it by 'examples' either on your site or included in the theme (category-1.txt - this is how you customize a category...)

    If you really need to have a category that looks that much different from the rest, wouldn't that be a good use-case for CPTs?

    Posted: 2 years ago #
  6. If you really need to have a category that looks that much different from the rest, wouldn't that be a good use-case for CPTs?

    You could indeed use CPT, but sometimes it's not really necessary, imagine that in some categories you wanted the posts to display it's thumbnail, and others you did not, or that you wanted a category to display it's posts styled like rectangles, etc.

    I can't see any disadvantage in this feature, it could even work like, if you apply a template to a category with children, you would have a checkbox which allowed to apply the same template to it's children or to keep their default template.

    Posted: 2 years ago #
  7. shazdeh
    Member

    This is easy to implement as a plugin, but I can't see the point. Could you give a use case of how a public-release theme would use it?

    imagine that in some categories you wanted the posts to display it's thumbnail, and others you did not

    I think this should be decided by the theme user and not the theme author, no?
    BTW, with the new WordPress settings API is really easy to have an option page where users can select which category will use which template.

    Posted: 2 years ago #
  8. And because it should be decided by the user, there should be an option for that when the developer creates category templates, making it available in the theme options is not very flexible in my opinion, but it's true, it only depends on the developer skills to make a clever way of selecting the templates.

    Posted: 2 years ago #
  9. Justin Tadlock
    Member

    12345

    If you really need to have a category that looks that much different from the rest, wouldn't that be a good use-case for CPTs?

    Not at all. Custom post types are for a different type of content. Besides, CPTs don't really belong in themes (another discussion for another day though). We're just talking about the output of the archive HTML. Some examples might be a gallery or list-style template as opposed to the standard excerpt view.

    This is easy to implement as a plugin, but I can't see the point. Could you give a use case of how a public-release theme would use it?

    This isn't plugin territory. See my reply above about term meta though. Even plugins would have to do this in a "hackish" way. There have been a few use-cases already discussed above.

    I think this should be decided by the theme user and not the theme author, no?

    That's the point of this topic.

    BTW, with the new WordPress settings API is really easy to have an option page where users can select which category will use which template.

    The Settings API isn't new. Nevertheless, this isn't exactly an ideal way to handle the data (though possible). Again, see my reply above about term meta.

    Posted: 2 years ago #
  10. Ipstenu (Mika Epstein)
    Half-Elf Support Rogue & Mod

    Besides, CPTs don't really belong in themes (another discussion for another day though).

    Oh I agree 100% on that :)

    Interesting, though. I'll kick this out of plugin territory.

    Posted: 2 years ago #

RSS feed for this topic

Reply »

You must log in to post.

  • Rating

    12345
    12 Votes
  • Status

    This idea is under consideration