Skip to content

Snippet: Insert Template Content via Theme Hooks

The following snippet shows you how you can insert a WPBakery template to your site via a hook, this is ideal for advanced usage where you may need to add custom conditionals so it doesn't show up on every page, however, if you are adding the template on every page you may want to instead use the theme's Custom Actions panel.

/**
 * Insert a Templatera template after the site header.
 *
 * @link https://total.wpexplorer.com/docs/snippets/insert-template-content-via-theme-hooks/
 */
add_action( 'wpex_hook_header_after', function() {
	$template = 100; // Change this to the templatera post ID you want to grab content from.
	echo do_shortcode( '[templatera id="' . $template . '"]' );
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top