• Hey Guys

    For my new site I built a category page (category.php) that means I can browse a top level category (/category/culture/) and a subcategory (/category/culture/reviews/) and they both utilise the same page (category.php) to list posts.

    Now I have a Custom Post Type (recipe) with a custom taxonomy (recipetypes – Meal, Snack etc)

    My custom post type ‘recipe’ has been registered in functions.php with
    'rewrite' => array( 'slug' => 'recipes'),
    So the URL is nicer – /recipes/

    And it correctly links to archive-recipe.php which is where I list recipes.

    But, when a term is clicked on the page (for example, for the recipetype “Meals”, get_term_link returns /recipes/meals/) I want to load the same template – archive-recipe.php – and just get the selected term from the query vars so I can filter the recipes shown on the page.

    All I’m getting is a 404 for pages like /recipes/meals/

    The WordPress docs say the taxonomy hierarchy goes like this:

    taxonomy-{taxonomy}-{term}.php
    taxonomy-{taxonomy}.php
    taxonomy.php
    archive.php
    index.php

    I have created all of the following pages to test, and still get a 404 for /recipes/meals/ – none of them are being loaded:

    taxonomy-recipetypes-meal.php
    taxonomy-recipetypes.php
    archive-recipe-meals.php
    archive-recipes-meals.php
    recipes.php
    recipe.php
    taxonomy-recipe.php
    taxonomy.php
    taxonomy-recipes.php

    Debugging WordPress rewrites I’m getting

    recipes/([^/]+)(/[0-9]+)?/?$ => index.php?recipe=$matches[1]&page=$matches[2]

    index.php exists, but it’s empty as I use front-page.php for my homepage, categories.php for my article categories, single.php for my article posts… now I’m trying to build the page structure for recipes.

    How can I make /recipes/{term}/ load archive-recipe.php?

    Thanks in advance 🙂

  • The topic ‘Taxonomy template hierarchy link to archive page help needed’ is closed to new replies.