Support » Fixing WordPress » use specified template for all post within specific category

  • Resolved lynkei


    I am wondering if there is a way to set all the posts within a certain post category to use a certain template.

    IOW, I have categories like this:

    • Bedroom
    • Dining Room
    • Living Room
    • Uncategorized

    I would for instance like to set any items within the uncategorized category to use template_01.php and the rest to use template_02.php. I am wondering how this would be done? I am willing to specify it for each individual category if that’s what it takes but since I will not be managing this site I don’t want to have the user select the template.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Can this be solved by adding a post_class? Meaning is the output completely different between the “templates” or is it just the styling?

    I guess an alternative would be a conditional statement looking for each category and switching “template_part” accordingly.

    Thanks “bythegram” for your quick reply.

    Basically here’s the deal, I actually have custom fields set up using the “advanced custom fields” plugin. uncategorized items actually have different fields then ones under the other categories.

    So what I’m trying to do is specify a page template for the different categories to display that info in the way I want it to.

    The post_class in that case won’t help me and if I’m understanding it right the get_template_part is not actually for templating pages rather loops etc? If so I don’t think that solves my issue. Or maybe i’m understanding this incorrectly?

    I’m having trouble understanding what you need, do you have an example code of how you are currently displaying your ‘info’?

    Could you use conditional checks to change how you display it?


    if (has_category('Uncategorized')) :
    //do this
    elseif (has_category('Dining Room')) :
    //do this instead

    Actually, as a matter of fact that has_category function would do it.

    Thanks for your help

    Sorry, meant to mark as resolved.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘use specified template for all post within specific category’ is closed to new replies.