Block Template in Plugin
-
I am trying to figure out how I can add in a block template from a plugin for specific url needs. We have a CPT being registered in the plugin and also a custom taxonomy. We want to have a sub-page of the CPT based on the custom taxonomy. ex( cpt-slug/post-slug/taxon-name/taxon-term )
The idea is that we want to have a page that is based on the CPT item and pass in a specific taxonomy. This is easy to handle with
add_rewrite_url
function, but what we are wanting to do is to render a specific block template through the plugin. So this would be like using thetemplate_include
hook, but instead of a PHP template, render out a block template. We are then wanting to allow for the theme to basically override the block template to customize as needed. The template from the plugin is to have a base template for rendering.I was trying to use the
get_block_templates
hook, which somewhat works, but when I add the same template in the theme’s templates folder, I end up with two templates showing up in the FSE screen and only the plugin template is rendering out and not being overridden by the theme template file.
- The topic ‘Block Template in Plugin’ is closed to new replies.