Skip to content

Instantly share code, notes, and snippets.

@themeblvd
Last active June 21, 2017 15:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themeblvd/e554de3b037737699545ef4c7cab3043 to your computer and use it in GitHub Desktop.
Save themeblvd/e554de3b037737699545ef4c7cab3043 to your computer and use it in GitHub Desktop.
How to use the standard page template with a custom layout in Theme Blvd WordPress Framework.
<?php
/**
* HOW TO USE STANDARD PAGE TEMPLATE WITH LAYOUT BUILDER
*
* 1. Copy page.php to your child theme and rename
* it "template_builder.php".
*
* 2. Copy the commented code snippet from the top of
* parent theme template_builder.php in place of the
* comment snippet in your new child theme template_builder.php.
*
* 3. Replace the while() loop in your new child theme
* template_builder.php file with the custom layout
* action hook:
*
* <?php do_action( 'themeblvd_builder_content', 'main' ); ?>
*
* 4. Implement the code snippets below to your child
* theme's functions.php.
*
* WARNING: This will cause several features to not
* work properly in the layout builder. But if you're
* just looking for a simple way to put builder content
* into standard page template, this will do the trick;
* just be aware this limits some features.
*/
/**
* On custom layouts, the sidebar layout option get
* surpressed; so here we'll force all custom
* layouts to have the site-wide default sidebar layout.
*/
function my_sidebar_layout( $sidebar_layout ) {
if ( is_page_template('template_builder.php') ) {
$sidebar_layout = themeblvd_get_option('sidebar_layout');
}
return $sidebar_layout;
}
add_filter( 'themeblvd_sidebar_layout', 'my_sidebar_layout' );
/**
* Add HTML that normally gets put before standard
* pages, which is skipped for a custom layout.
*/
function my_before_layout() {
if ( is_page_template('template_builder.php') ) {
do_action('themeblvd_main_start');
do_action('themeblvd_main_top');
}
}
add_action( 'themeblvd_before_layout', 'my_before_layout');
/**
* Add HTML that normally gets put after standard
* pages, which is skipped for a custom layout.
*/
function my_after_layout() {
if ( is_page_template('template_builder.php') ) {
do_action('themeblvd_main_bottom');
do_action('themeblvd_main_end');
}
}
add_action( 'themeblvd_footer_before', 'my_after_layout');
/**
* Most likely you don't have a full-width sidebar
* layout selected if you're doing this; so we need
* to make sure the full-width narrow content feature
* doesn't get enabled as it by default on custom layouts.
*/
function my_do_fw_narrow( $do ) {
if ( is_page_template('template_builder.php') ) {
$do = false;
}
return $do;
}
add_filter('themeblvd_do_fw_narrow', 'my_do_fw_narrow');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment