Archive-style page for a custom taxonomy - wordpress

I've been trying with no luck to use built-in template hierarchy to get a simple page that would list all terms for a custom taxonomy.
I have a custom taxonomy "editions" (linked to a custom post type "courses").
I have my template that I named "taxonomy-editions.php" (also tried archive-editions.php) which is called when I try to access a given edition (/editions/2016 for example, and archive-editions.php does the same btw). But whenever I try to access /editions/, no template is called (apart from index.php).
Am I doing something wrong here, or is it simply not possible to do that without creating a custom page ? (most of the answers I've found are 2 years old or more).
Thank you in advance

If you are using the custom taxonomy , then please use the following templates for custom taxonomy and just copy the archive code over this template.
taxonomy-{taxonomy}-{term}.php
taxonomy-{taxonomy}.php
tag-{slug}.php
tag-{id}.php
category-{slug}.php
category-{ID}.php
Also don't forget to use this variables as true when you registering the taxonomy,
publicly_queryable=>true
hierarchical=>true
You can check the usage of register_taxonomy here.

Related

Parent permalink slug before CPT slug

I'm currently busy making a FAQ for my website but i'm struggling with the permalink structure.
I have made a regular page where people can see an overview of the FAQs. I called that page Klantadvies.
I installed a Custom Post Type plugin and made a post type called faq. I also made a taxonomy which is called onderwerp.
Unfortunately the plugin won't allow me to have a page parent in the slug. So i'm wondering if it's possible to have my page slug (klantadvies) in front of the custom post type slug. For example:
http://mypage.com/klantadvies/faq/onderwerp
Thnx in advance!
Rather than using a plugin for your post types and taxonomies, I'd recommend you use these two solutions:
https://generatewp.com/post-type/
https://generatewp.com/taxonomy/
You can use those to create your Post Type and Taxonomies. Within each of those configs you're allowed to setup the slugs / URL structure that you want to use.
On top of that you're going to need to setup a custom rewrite rule to handle echoing out the values you're looking for on the appropriate layout.
https://codex.wordpress.org/Rewrite_API/add_rewrite_rule

Wordpress getting template for post category type to work

Hiall,
In my wordpress site I have a Category called “meetings”, and it’s slug is “meeting”, also its ID is 27.
I create a default post article and then select “Meeting” from the categories panel and then publish etc.
Reading here
http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display
If I create a template file called category-meetings.php or category-27.php then it should pick those files up and use them for a template layout for my selected Meeting category posts etc???
But for whatever reason I can not get it to do this.
I have also tried changing the permalinks settings from “post name” to custom structre with /%category%/%postname%/
but again no luck.
Am I missing something here?
Any help would be great!
I think you're trying to target a single post, whereas your template is targeting the category archive pages. For example, look at this diagram of the template hierarchy.
You could:
1) Create that post as a page and then create a template just for that page.
2) Create a custom post type and create a custom template for that custom post type.
The naming has to match your slug. I would change
category-meetings.php
to
category-meeting.php
And make sure the category-customname.php files are in the same directory as the default category.php file.
Addition/Revision
For a custom page for a single post -- find the post number, let's say 999, then create a single page with the past number appended to the file name in the same directory where the single.php file exists. This worked up to WP ver 3.2-ish. Unless it's been deprecated, it should still work.
single-999.php

how can i create archives for custom post type

the WordPress framework allows to build different archive templates for each of your custom post type by e.g:
archive-event.php
taxonomy-event_category.php
is it possible to create author and date archive for custom post type by doing the following:
author-event.php
date-event.php
if this is not possible, can anyone advise how i can go about achieving this?
I think these links will help answer your question and get you started:
http://codex.wordpress.org/Template_Hierarchy
http://codex.wordpress.org/Category_Templates
The gist of it is that you can in fact make an author-event.php however date-event.php does not get checked because the template hierarchy dictates that it uses date.php, archive.php, or index.php.
One solution is to use conditional tags such as is_author() or is_date(). If you do, keep in mind that you'll have to have a common archive.php and decide which template you really want to use by using conditional tags.

WordPress - specific file for custom post type

I know I can create custom files for specific custom-post-types
Unfortunately, the method works for me in one case:
page-results.php for CPT = results
but does not work for page-news.php where CPT = news
or does not work for page-events.php where CPT = events
Why? can you have just a single file like that?
This might clarify some things for you:
Wordpress Template Hierarchy
The problem is, your Custom Post Types aren't actually "Pages". Even a "Page" isn't technically an actual Page, but a hierarchical Custom Post Type called "Page". Confusing? Yes. But there's a method to the madness.
The built-in Post Type known as "Pages" do function differently than the built-in Post Type called "Posts", which is why they have their own default templates and hierarchy. However, despite the fact that Wordpress allows you to extend their core to include your own Custom Post Types, at their root they're still considered "Posts" and will not follow the "Page" branch.
Your two options if you're following the standard Template naming conventions is to name your Custom Post Archive Templates "archive-results.php", "archive-news.php", and "archive-events.php".
As for your Custom Post Single Post Template, you would name them "single-results.php", "single-news.php", and "single-events.php".
If you want to fall back on an archive or single template for all three custom post types, simply don't define the separate post types and define an "archive.php" and "single.php" file.
Here's some more information on Custom Post Type Templates

Wordpress: use custom category template (category.php) for different custom post type

i need to customize my category.php template depending of which custom post type the cat is attached (assuming every post type has dedicated categories, not shared between pt, and dynamically created by site admin user).
Alternative to this can be load different template (category-slug.php?) but codex says category.php is only and one.
Any suggestion?
Solved by a link provided by Vasanthan.R.P
https://wordpress.stackexchange.com/questions/10099/custom-post-types-on-category-pages
Try this solution.
http://wordpress.org/support/topic/category-template-for-custom-post-type
or you can try this one too
https://wordpress.stackexchange.com/questions/10099/custom-post-types-on-category-pages

Resources