Forums

want taxonomy.php to separate my custom post types (5 posts)

  1. rrswans
    Member
    Posted 5 months ago #

    I have created two custom post types for my website called, "art" and "design"

    I have additionally created a series of custom taxonomies called, "color", "media", "project", ect. Both post types share these taxonomies.

    All of this works great. The issue I am having is that throughout my site I am using colors in my header to let the user know where they are. For example, When they are viewing the art-archive.php page everything is yellow. When they are on the design-archive.php page everything is orange. I was able to do this with the single posts as well.

    The problem is with the taxonomy.php page. Since they both use this template I can't change the colors with way I did with the "art-archive.php" template. I tried making a art-taxonomy.php page but that didn't work.

    I know I could go in and build mirror taxonomies for each post-type and then create separate taxonomy-color.php files, but that seems like a lot of work, and difficult to maintain in the future if I want to add more taxonomies.

    Is there anyway to have a single, or maybe 2 taxonomy pages that keep my post-types separate while having independant style? SO that I could query "color" just from "art" and have the resulting page have a different color scheme than if I queried "color" from "design"?

  2. Chip Bennett
    Member
    Posted 5 months ago #

    Please refer to the Custom Taxonomy section of the Template Hierarchy Codex entry.

    If you have a custom taxonomy named "color", use a template file named taxonomy-color.php.

    If you have terms such as "yellow" or "blue" in the "color" taxonomy, then use template files named taxonomy-color-yellow.php or taxonomy-color-blue.php.

  3. rrswans
    Member
    Posted 5 months ago #

    Thanks Chip, I understand that, and maybe that is what I have to do. I'm wondering if I can simplify and create less templates.

    Is there no way to just make a 'taxonomy-design.php' template that will display the results of any taxonomy assigned the custom post type of "design"?

  4. Chip Bennett
    Member
    Posted 5 months ago #

    Is there no way to just make a 'taxonomy-design.php' template that will display the results of any taxonomy assigned the custom post type of "design"?

    Again, check the Codex reference. Is there any particular reason you can't use archive-design.php for "design" post-types?

  5. rrswans
    Member
    Posted 5 months ago #

    I originally searched through the template hierarchy, custom taxonomy and custom post types in the codex before I posted. They don't mention anything about a taxonomy template that pulls directly from post types.

    The design-archive.php is already in use. I've got a few hundred entries. I'm using the taxonomies to narrow that down.

    I think I may just go ahead and make all the taxonomy-color.php templates. Doesn't seem to be a way to relate the post-type with the taxonomy in a query

Reply

You must log in to post.

About this Topic