Block template for custom post type
-
Hi, I’m creating a plugin that adds a custom post type and I want to provide a template that can be then overwritten by the theme. I know that in the theme /template folder you can just put a ‘single-post-type.html’ and it will be loaded as template for every post of ‘post-type’, I’m trying to provide the default one with this method:
add_filter('template_include', 'include_template_file'); function include_template_file($template) { if(get_post_type() != 'tagfilters_page') return $template; return plugin_dir_path(__FILE__) . 'partials/tag-filters-page-single.html'; }
But it doesn’t correctly load the block template (for now I just copied the template from ‘single.html’ in theme twentytwentytwo), it just shows an empty page and if I inspect it the HTML comments for the block theme are still there.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Block template for custom post type’ is closed to new replies.