• Resolved garbonzo

    (@garbonzo)


    Hi all,

    How do you suggest I go about doing this:
    I want my sub-categories to use my theme’s default category index.php, but I want the parent categories to use a different one that I hacked together.

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Wrong approach ??
    You cannot have another “index” – that would break WP.
    However, you should read about the Category Templates:
    https://codex.www.ads-software.com/Category_Templates

    Thread Starter garbonzo

    (@garbonzo)

    Thanks for the link. After reading, I think I’ve got a way:

    A customized category.php that pulls that category name into an if/then condition. If the category is a parent category, then display the loop using html template “A”.
    Else, the category must be a child-category, in which case, display the loop using html template “B”.

    What do you think?

    I am not sure I can follow you. I am not a coder, so I’d never know how to write a code to recognize a parent or child cat.
    Actually you can have N+1 category templates.

    Also, be aware, Catgeory Templates are used by WP to display category archives (the posts listed when you click on a cat name) – NOT for displaying single posts.

    Sorry, I should have clarified this at the beginning.
    If you want the single posts to have different templates based on category, you need this plugin:
    https://guff.szub.net/2005/07/21/post-templates-by-category/
    (and if you feel confused by now, check out the Category Hierarchy in the Codex)

    Thread Starter garbonzo

    (@garbonzo)

    Ah, category hierarchy helps. Thanks Mo!

    Hmmm… I am getting old and tired. I meant TEMPLATE hierarchy.
    https://codex.www.ads-software.com/Template_Hierarchy

    Thread Starter garbonzo

    (@garbonzo)

    Yeah, I found that page when doing a search for ‘category hierarchy’.

    I should have mentioned that earlier, because otherwise my above post sounds like I’m being sarcastic. Which I wasn’t.

    Anyhoo, thanks again.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘how to do diff. index.php for category and sub-category?’ is closed to new replies.