Naming a template of custom taxonomy - wordpress

I am building a site in Wordpress were I have created 1 custom taxonomy named cars.
This taxonomy consists of several posts that work as follows:
if user goes in a page of the above taxonomy a list of cars as images is displayed.
by clicking to a car image he is forwarded to a new page with the list of images containing the specific car-model (brand).
My objective is to create 2 page templates as introduced by the template hierarchy:
taxonomy-cars.php
taxonomy-?.php
The first template will be named taxonomy-cars.php.
My problem is that I don't know how to name the second layer page template.

A taxonomy is composed of terms. I suppose in your case you have the cars taxonomy where the "brands" are one of the possible terms.
From the Template Hierarchy documentation:
taxonomy-{taxonomy}-{term}.php - If the taxonomy were sometax, and taxonomy's term were someterm WordPress would look for taxonomy-sometax-someterm.php.
So, try taxonomy-cars-ford.php.

Related

How to create subpages for taxonomy term page in wordpress?

I have created a custom taxonomy and what the term page will look like.
domain.com/taxonomy/term
But for each taxonomy term, I have included various custom fields and included content. The content is large and I want to display them in subpages with individual link clicks. I want to display them in subpages.
For eg:
domain.com/taxonomy/term/meta-data-1
domain.com/taxonomy/term/meta-data-2
How can I create this?
I am using Genesis Framework
I'm assuming you have some knowledge in php and Wordpress theming.
You could create/add a custom-subterm then create a specific template for that custom-subterm called taxonomy-custom-subterm.php.
Inside you could display all relevant informations/metadata to the custom-term.
If your custom-taxonomy is set to hierachical (which is the default behaviour I believe), then the url should be /custom-taxonomy/custom-term/custom-subterm/.
Graphical representation
domain.com/
L custom-taxonomy/
L custom-term/ (using taxonomy.php OR taxonomy-custom-term.php as template)
L custom-subterm/ (using taxonomy-custom-subterm.php as template)
This is based around the default Wordpress hierarchy.
Learn more # https://developer.wordpress.org/themes/basics/template-hierarchy/.
And # https://developer.wordpress.org/files/2014/10/Screenshot-2019-01-23-00.20.04.png

How do I make a tag taxonomy page?

I have woocommerce plugin. I created a custom tag taxonomy under products to pick the product ingredients. ( https://pasteboard.co/J2BlgqI.png ). To show them as buttons on the product page ( https://pasteboard.co/J2Bn7FD.jpg ).
Now I want the visitor when they click on the ingredient it shows them an ingredient page information. So, if they click on “Beeswax” it shows them Beeswax information like name, function and etc…
Each time I click on “Beeswax it directs me to a filter page https://pasteboard.co/J31hg2w.png .
How can I make a page for each ingredient?
Is it even doable this way? or is there another way to accomplish this?
please advice…
thanks
Yes you can have custom templates for your taxonomies. The template hierarchy explains everything.
Custom taxonomies use this template file path:
taxonomy-{taxonomy}-{term}.php – If the taxonomy is sometax, and taxonomy’s term is someterm, WordPress will look for
taxonomy-sometax-someterm.php. In the case of post formats, the
taxonomy is ‘post_format’ and the terms are ‘post-format-{format}.
i.e. taxonomy-post_format-post-format-link.php for the link post
format.
taxonomy-{taxonomy}.php – If the taxonomy were sometax, WordPress would look for taxonomy-sometax.php.
taxonomy.php
archive.php
index.php
Since you haven't created a taxonomy-ingredients.php WordPress uses the next available option and falls back to the generic template.
You can even create a different template (page) for each of your Ingredient by using the first option above.

looping different custom taxonomies with single page template

I have a main custom taxonomy page templates which call "product" it will show all the product in a single page.
But I have lot of sub taxonomies under product wanna show each in different page.
I know I can create as much as taxonomies categories page for each sub category but is there any way I can do it with a single template to fulfill all the looping?
You don't need to create pages for each taxonomy term, you could create a file called taxonomy-{taxonomy}.php in your theme's directory (which {taxonomy} is the name of taxonomy you crated) and it will load for each taxonomy term you create. for more information read Taxonomy Templates docs.

Add taxonomy terms list to homepage Drupal 8

Please help me to add taxonomy terms from custom taxonomy into home page. I have no idea how to do this as I'm coming from WordPress. In WordPress it is easy as calling get_terms(). I have following file as my home page: mytheme/templates/page--front.html.twig
I have more than one taxonomy type and all of them are going to queried in the home page.
How to query the taxonomy terms?
UPDATE:
I have created a new region called home_content in my theme.info.yml and I have created a view(block) for getting the taxonomy terms, added it to region in back-end and display it as {{page.home_content}}. It works but I have few questions.
I have fields for logo and text in the taxonomy. I want to list them too.
I need to customize the html. How can I do that?
Thanks for the support.
You don't really need to code anything
Create view with taxonomy terms required. Structure > Views > Create New View and add block view for taxonomy terms. User filter section to select specific terms or dictionaries. Save the view.
Go to Structure > Block Layout and insert block with your view into desired region. In visibility section, pages tab: type <front> in pages and select Show for the listed pages in order to display it on home page only.
Above steps will display your required terms on home page.
To copy and modify template(s) in your theme, follow the instructions on drupal.org: https://www.drupal.org/node/2358785

I have a personal taxonomy i.e car and i want to have a template to show car relevant post

I have created a custom post type named vehicles and there are different categories for that like trucks, cars, vans etc. I have created a taxonomy named vehicles-categories and now I want to show posts from taxonomy like cars on specific page which will show only posts from that certain category/taxonomy.
I have written WordPress custom loop but it does takes me to index.php page while I want different styles for that cars page.
Can anyone figure out what's am I doing wrong?
You have to create a custom template for your taxonomy to show posts from that specific taxonomy.
In your case if you want to show posts from term "car" then your template name will become taxonomy-vehicles-categories-car.php and WordPress will show posts on this page (you can style and get data according to your needs in this template).
Similarly, you can create taxonomy-vehicles-categories.php page to show posts from this taxonomy and can code this page to show posts as you want.
For further and in-depth understanding about how WordPress uses taxonomy template files visit the official codex page.

Resources