4%29 Preview template - ChrisWinters/includes GitHub Wiki

When previewing an Include a custom empty template is used to display the content - this feature can be enabled and disabled within settings. The preview is only viewable to logged in administrators. The purpose of the blank template is to show off an example of saved Includes to ensure the content works as expected.

Advanced users can override the default template by creating the file template-parts/includes-preview.php. Once defined the plugin will automatically use that template to preview saved Includes.

Customize the template

The preview template comes with two action hooks before and after content display.

Before content hook

Template hook: do_action('includes_before_content');

Example callback

/**
 * Open container, row, and col before included content.
 */
function includes_before_content(): void {
	$html  = '<div class="container">';
	$html .= '<div class="row">';
	$html .= '<div class="col">';
	return $html;
}

add_action( 'includes_before_content', 'includes_before_content' );

After content hook

Template hook: do_action('includes_after_content');

Example callback

/**
 * Close col, row, and container after included content.
 */
function includes_after_content(): void {
	$html  = '</div><!-- .col -->';
	$html  = '</div><!-- .row -->';
	$html .= '</div><!-- .container -->';
	return $html;
}

add_action( 'includes_after_content', 'includes_after_content' );
⚠️ **GitHub.com Fallback** ⚠️