Custom Taxonomy Template/Archive
-
Hey all, I’m having some trouble figuring out how to display custom taxonomies. I’ve created a custom post type called ‘work’ and a custom taxonomy for ‘work’ called ‘project-type.’ Here’s the code I used to create the taxonomy:
add_action( 'init', 'create_my_taxonomies', 0 ); function create_my_taxonomies() { register_taxonomy( 'work_project_type', 'work', array( 'labels' => array( 'name' => 'Project Types', 'add_new_item' => 'Add New Project Type', 'new_item_name' => "New Project Type Name" ), 'rewrite' => array( 'slug' => 'project-type' ), 'show_ui' => true, 'show_tagcloud' => false, 'hierarchical' => true, 'has_archive' => true ) ); }
In the WordPress admin dashboard, I created several project types (ex. video, photography, web design, etc.). Here’s my question: how do I display a list of all the items in each project type? For example, I’d like to be able to click ‘photography’ and see a list of all the posts in the ‘photography’ category. Currently, when I go to https://mydomain.com/project-type/photography/ it displays all of the posts in the custom post type ‘work’ rather than just those in ‘photography.’
From looking at the WordPress Template Hierarchy, it looks like I should create a file called template-project-type.php, but I’ve tried that and it isn’t working. I also tried template.php, template-project_type.php, template-work_project_type.php but none of them are working. Help?
(P.S.- Here’s my site.)
- The topic ‘Custom Taxonomy Template/Archive’ is closed to new replies.