0

I have added a new custom post type "Movies" to my wordpress site, and added 3 taxonomies to that post type "Genres & Year & Author".

Now, i want to make a custom template which wordpress will use if someone access the page of any of these three taxonomies: eg. if some one accessed the taxonomies pages: "www.sitename.com/genres", "www.sitename.com/year", "www.sitename.com/author".

how can i make a custom template for all taxonomies under "Movies" post type?

  • archive-movies.php will show all posts of these taxonomies. For each taxonomy you can use taxonomy-genre.php , taxonomy-author.php , taxonomy-year.php – Piyush Rawat Nov 16 '17 at 7:19
0

create specific taxonomies template for Genres & Year & Author like this :

taxonomy-genres.php
taxonomy-year.php
taxonomy-author.php
  • Thank you for helping, but i was wandering if it's possible to use one template that display posts depending on the requested taxonomy of a custom post type. eg. Archive.php is responsible for displaying posts of the selected category of all post type, as i have 5 custom post types and if i created a file for each taxonomy the result will be huge number of files! – Mohsen Abdelhameed Nov 16 '17 at 10:19
0

You cannot differentiate the templates for taxonomies according to the post types. You can do that for taxonomy terms. Your best options will be to create separate templates as suggested by Balwant or use a conditional loop for these three taxonomies in your default taxonomy page.

if(is_tax( array('genres', 'year', 'author') ) {
  //your custom template path here
}

Hope this helps. Thanks

0

Create templates by category ID OR Category Slug like (Category name: mobile) taxonomy-mobile.php

taxonomy-id.php

category-mobile.php

category-id.php

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.