I can’t figure out which template name to use to modify custom taxonomy archive page, but not the one for terms in that taxonomy.
My goal is to show terms list in custom taxonomy archive and in custom taxonomy terms – custom post types..
{taxonomy}-{term}.php is used to display custom taxonomy terms ( so there will be custom post types inside ) but i need so there would be terms list inside.
Hope my question in clear.
Edit:
Just found out that I can’t open that kind of page in wordpress at all..
So now question is how to make such page?
For ex. I have ct – device. So /device/iphone will show all posts in iphone term,
but /device/ should show all terms in device tax.
My problem is that /device/ is readed as page slug, not tax in wordpress by default.
How to change that?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
There is no such hierarchy in WordPress, accessing a custom taxonomy directly simply 404. This works for all taxonomies, build-in or not. There is unfortuantely no other work around to this but to create a page
You should create a custom page template with a custom query to list your taxonomy terms, something like the following
-
Create a page template called
page-device.php -
Use
get_terms()to create your list, something like this: (Extend as needed, taken from theget_terms()page)$terms = get_terms( 'device' ); if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ echo '<ul>'; foreach ( $terms as $term ) { echo '<li>' . $term->name . '</li>'; } echo '</ul>'; } -
Create a page in the back-end with slug
device
Now, if you visit mysite.com/device/, you will see this page showing up with all your terms in the taxonomy device
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0