custom post types – How to assign a single-menu-template to a menu-items in a taxony/ cat/ subcat/ subcat-item
Question
Hi hope really someone can assist.
I have created a single-meny-template with post-type-meny, and I have created taxonomy, categories, sub-categories and subcat-items.
What happens is that the templates gets assigned to /psk/meny instead of /psk/meny/cat/subcat/subcat-item.
//Single-meny-template with post-type-meny
/*
Template Name: Single Meny Template
Template Post Type: meny
*/
This is my function hook the template.
custom_template_for_meny_items($template) {
global $post;
// Check if we have a valid post object
if (is_a($post, 'WP_Post') && $post->post_type === 'meny') {
// Check if the custom template exists in the theme
$custom_template = locate_template('templates/single-meny-template.php');
if (!empty($custom_template)) {
return $custom_template;
}
}
return $template;
}
add_filter('template_include', 'custom_template_for_meny_items');
Thank you for clearifying.
0
3 months
2023-09-02T12:47:05-05:00
2023-09-02T12:47:05-05:00 0 Answers
0 views
0
Leave an answer