I’m having some trouble with my crowdfunding site where I’m using Bricks Builder along with the Ignition Deck plugin. Here’s what’s up:
I’ve created a custom template in Bricks that’s supposed to apply to the custom post type that IgnitionDeck sets up. I did everything right on my end, but for some reason, the template just won’t show up on the front end.
Here’s what I’ve tried so far:
Cleared and flushed permalinks.
Reactivated both the plugin and the theme.
Made the post type hierarchical (it’s not by default), but that didn’t help.
I’ve been scratching my head trying to figure out why this custom template isn’t working. Any ideas or suggestions would be greatly appreciated!
this is all done locally, no online staging for this yet.
I don’t know the plugin, but if it provides its own templates, they might override the Bricks templates. It’s probably best to contact the plugin devs first to see if this is the case and if there’s a way to prevent it / to make the plugin compatible with Bricks. If the plugin devs have any questions, they can always contact us by email, and we will help as best we can.
Thanks @timmse — is there anything that you all know of that a plugin providing templates that it should avoid doing so that Bricks template logic works as expected? WooCommerce provides templates and Bricks custom templates override them easily.
@timmse - I ended up having to create a PHP class to get the appropriate template to load and then include the templates within my plugin. Essentially, I’ve built an addon that creates dynamic data tags that output IgnitionDeck data.
<?php
/**
* Main plugin class
*
* @package Bricks_For_IgnitionDeck
* @since 1.0.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Main plugin class to handle initialization and hooks
*/
class ID_Bricks {
/**
* Instance of the class
*
* @var ID_Bricks
*/
private static $instance = null;
/**
* Tag Manager instance
*
* @var ID_Tag_Manager
*/
public $tag_manager;
/**
* Tag Renderer instance
*
* @var ID_Tag_Renderer
*/
public $tag_renderer;
/**
* Constructor
*/
private function __construct() {
$this->load_dependencies();
$this->init_components();
}
/**
* Get the singleton instance
*
* @return ID_Bricks
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Load required files
*/
private function load_dependencies() {
require_once ID_BRICKS_PLUGIN_DIR . 'includes/class-tag-manager.php';
require_once ID_BRICKS_PLUGIN_DIR . 'includes/class-tag-renderer.php';
}
/**
* Initialize plugin components
*/
private function init_components() {
$this->tag_manager = new ID_Tag_Manager();
$this->tag_renderer = new ID_Tag_Renderer();
// Register template hooks
add_filter( 'template_include', array( $this, 'template_include' ) );
add_filter( 'bricks/builder/i18n', array( $this, 'register_post_type' ) );
add_filter( 'bricks/templates/post_types', array( $this, 'add_template_support' ) );
}
/**
* Register template for IgnitionDeck products
*
* @param string $template The current template path
* @return string Modified template path
*/
public function template_include( $template ) {
// Only run for ignition_product post type
if ( 'ignition_product' === get_post_type() ) {
// Check if theme has its own template
$theme_file = locate_template( 'single-ignition_product.php' );
if ( $theme_file ) {
// Use theme file if it exists
return $theme_file;
} else {
// Use our plugin template
$plugin_template = ID_BRICKS_PLUGIN_DIR . 'templates/single-ignition_product.php';
if ( file_exists( $plugin_template ) ) {
return $plugin_template;
}
}
}
// Return original template if conditions not met
return $template;
}
/**
* Register ignition_product post type with Bricks
*
* @param array $i18n The i18n array
* @return array Modified i18n array
*/
public function register_post_type( $i18n ) {
if ( ! isset( $i18n['postTypes'] ) ) {
$i18n['postTypes'] = array();
}
$i18n['postTypes']['ignition_product'] = 'IgnitionDeck Product';
return $i18n;
}
/**
* Add Bricks template support for ignition_product
*
* @param array $post_types Supported post types
* @return array Modified post types array
*/
public function add_template_support( $post_types ) {
$post_types[] = 'ignition_product';
return $post_types;
}
}