1

Is there any method to create different template in a theme for different category tags search? For example, I have category 'blog' and category 'glossary' - there is no any similar tag for both categories. I need to open tags from blogs this way: /blog/tag/any-tag-blog /glossary/tag/any-tag-glossary

what method can I use in the theme for splitting tags result and to have different template pages for these categories?

0

You can make the following templates named:

category-blog.php
category-glossary.php

If these are custom taxonomies:

taxonomy-blog.php
taxonomy-glossary.php

Source:

https://developer.wordpress.org/files/2014/10/Screenshot-2019-01-23-00.20.04.png

1
  • I know this way but this is not what I need. 'Blog' and 'Glossary' are posts categories - they have different templates. The posts have their tags - posts from blog category have any tags and posts from glossary category have other tags. I need the templates for 'blog/tag/some-tag' and other template for 'glossary/tag/other-tag' . I found a way with $_GET. But this is not same. – ALexander Lead Dec 15 '20 at 9:21
0

Dedicated tag or category pages are very doable.

You would use the following format category-catslug.php for each tag you want a special template for.

There is a help page covering this in greater detail.

Here is the hierarchy of files for templates in WordPress.

enter image description here

To then show tags on the category page, you would have to write some custom code in the custom category file to use the loop with wp_query to generate your results. Probably by inspecting $wp->request and/or $wp->query_vars.

2
  • I asked for another thing. This template is for a tag (tag-{slug}.php – If the tag’s slug is sometag, WordPress will look for tag-sometag.php.) I am looking for template which will combine category + tag template. I found a decision in URL like this: //site.com/category/?tag=sometag . But I try to find a decision to open like this: site.com/category/tag/sometag - the template should be same for all tags in this category, for another categories tags I need another template. – ALexander Lead Dec 19 '20 at 6:45
  • @ALexanderLead I see. I've updated my answer to reflect this part of the question. – Matthew Brown aka Lord Matt Dec 24 '20 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.