Using Roots with a custom taxonomy

Posting this here for anyone else that has the same problem…

Problem: After creating a custom taxonomy (‘issue’), I was having a problem where if I went to an archive page for that issue (e.g. /issue/issue-01) then items in that archive were repeated over and over again (I assume until some internal buffer limit is reached). I happened to notice that if I manually modified the URL to /category/issue/issue-01 then the page displayed as I expected.

Solution: After another post pointed me to the WP Template Hierarchy I realized that I didn’t have a taxonomy.php file. A quick cp category.php taxonomy.php later and my issue archive page worked as intended.

What I’m still unclear on was why the content of the page was repeated over and over again when using the category template. I am using an older version of Roots (somewhere just before the 6.5 release) so maybe its just a bug in my version?

1 Like

Roots doesn’t include a category, taxonomy or archive template, so the hierarchy will have defaulted back to the index template when loading a taxonomy.

A recurring loop of posts is usually the result of an un-reset custom query, so I would check your index template (or archive if you have one) to see if there’s a rest missing or you may encounter other similar bugs.

Hey all - loving the roots theme.

I am having a few problems with templates. Does anyone know what files i need to create for a taxonomy?

I’ve tried a lot but getting nowhere. And is there a way for the theme to echo out what template its actually using as my normal Wordpress feedback isn’t working - i.e.

<!--
 <? print_r( debug_backtrace() ) ?>
 -->

this url is giving me 404 - /media-tag/recent-work/

Same as any other WordPress theme. See Template Hierarchy | Theme Developer Handbook | WordPress Developer Resources.

A 404 has nothing to do with templates, because at the lowest level Roots will be using index.php for taxonomy and tag templates.

its not using index.php as i’ve manually labelled it.

I’ve already tried the WP method — the method i’ve been using for the last 5 years & Its not working.

Is there a debug function that shows me what template its selected?

My plugin here will show you the main and base templates being used.

The wrapper adds one step to the template hierarchy, but it doesn’t change it. Have you tried flushing the rewrite rules by visiting the permalinks page?

Freakin’ cool man. Thanks!

If someone after taxonomies they do not work, give a 404 error, it is necessary to pass “wp-admin” -> “Settings” -> “Permalinks” and press button “Save”.

At the root of the template is a file “roots/index.php”, he tells us how to handle the file “category (output categories)” - <? Php get_template_part ('templates/content', get_post_format ()); ?>

I do taxonomy “Services”.

In your templates, I named the files as follows:

http://joxi.ru/Az8yVP3JTJCbZ729w18

“roots/templates/content-services.php” - is responsible for handling categories
"roots/templates/content-single-services.php" - is responsible for processing a single page

at the root of the template “roots” to create a file:

“roots/single-services.php” - it put the following code <? php get_template_part ('templates/content', 'single-services'); ?>, Ie in this file, I show that a single record in the file is processed - “roots/templates/content-single-services.php”

also at the root of the template I created a file “roots/index-services.php”, which placed:

<? php while (have_posts ()): the_post (); ?> 
   <? php get_template_part ('templates/content-services', get_post_format ()); ?> 
<? php endwhile; ?> 

as it did loop, everything works perfectly, but the file is not processed - “roots/templates/content-services.php”, instead vozvraschaetsya to the “roots/index.php”. Which contains the code:

<? Php get_template_part ('templates/content', get_post_format ()); ?>

In the file. Therefore, one file is processed at all taxonomies - “roots/templates/content.php”

It turns out that as a taxonomy, everything works perfectly, except for the display of data categories taxonomies, because there is something that brings index.php. Therefore it is necessary to understand how to properly name the file “roots/index.php”?

The options are:
“roots/loop-services.php”
“roots/index-srvices.php”
“roots/services-index.php”
“roots/category-srvices.php”

Not one bit of it does not load. If we get together to solve this problem, all turn. :slight_smile:

Sorry for my bad english.

Updated: The right decision at the root to create a “root/archive-services.php” and it do as well as in “root/index.php”