• Resolved shelkie

    (@shelkie)


    Great plugin! You’ve made some blocks that come in very handy πŸ™‚

    One thing that would help greatly is to allow custom block templates to be used, since sometimes the desired layout can’t be achieved by overriding your CSS.

    With the way you have structured things, this is very easy to do (at least for the front-end)

    In the block controller (eg. classes/Blocks/Post.php), on line 78 change

    // Get template
    include Consts::get_path() . 'public/templates/post.php';

    to

    // Get template
    include apply_filters('advanced_gutenberg_blocks_template', Consts::get_path() . 'public/templates/post.php', 'post');

    then we can add a filter to specify our own template:

    /**
     * Custom templates for Advanced Gutenberg Blocks
     *
     * @param $path
     * @param $type
     */
    function advanced_gutenberg_blocks_template($path, $type){
    	if ($type == 'post'){
    		$path = get_template_directory() . '/block_templates/post.php';
    	}
    	return $path;
    }
    add_filter('advanced_gutenberg_blocks_template', 'advanced_gutenberg_blocks_template', 10, 2);
    • This topic was modified 5 years, 7 months ago by shelkie.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Please add template filter’ is closed to new replies.