I have been looking around for the past few hours and I am starting to be kind of desperate...
I have created a plugin to add my custom post type "project" (making a new portfolio)...
In this plugin, I have the function file, and a template file single-project.php and also a template part folder with content-single-project.php within it. On that part, everything is working fine just as I want...
To be able to load the template file from the plugin folder, I did the following in the function file:
function get_custom_post_type_single_template($single_template) {
global $post;
if ($post->post_type == 'project') {
$single_template = dirname( __FILE__ ) . '/templates/single-project.php';
}
return $single_template;
}
function get_custom_post_type_archive_template($archive_template) {
global $post;
if ($post->post_type == 'project') {
$archive_template = dirname( __FILE__ ) . '/templates/archive-project.php';
}
return $archive_template;
}
function get_custom_post_type_category_template($category_template) {
global $post;
if ($post->post_type == 'project') {
$category_template = dirname( __FILE__ ) . '/templates/category-project.php';
}
return $category_template;
}
add_filter( 'single_template', 'get_custom_post_type_single_template' );
add_filter( 'archive_template', 'get_custom_post_type_archive_template' );
add_filter( 'category_template', 'get_custom_post_type_category_template' );
Since it is working fine for the single template file, I don't see why I have a problem making it work for a category (or even archive) page... The category is not a custom taxonomy, it is the default (if I'm correct.. ) Category of Wordpress, same for Tags...
They are added in the project CPT while registering the new post type in the function file of the plugin, like so:
'taxonomies' => array( 'post_tag', 'category' ),
They are "classic" right ?
Well... My primary navigation is displaying those categories (I have 3, Frontend, Design, Apps... ). When clicking on any of those links, redirecting to an URL like "root/category/post-name/", the 404 template is loaded, not the category template from the plugin folder, neither the one from the theme folder, neither archive... etc. Just the 404 template.
My permalinks are flush, I tried all the posts I have found online and nothing is changing, still not working...
I hope you guys will understand my english and will be able to help, Feel free to ask any question, Thank you for your time.