paullacey78
7/28/2017 - 3:07 PM

Force GP into full width, hide page header & title and force layout to no sidebar with Beaver Builder is active on a page.

Force GP into full width, hide page header & title and force layout to no sidebar with Beaver Builder is active on a page.

<?php
/* GENERATEPRESS & BEAVER BUILDER SETUP */

/*  Automatically activate full width, hide title, and set no sidebar
    layout in GeneratePress if Beaver Builder is installed and enabled */

/** full width & hide page header unless custom header is enabled in GeneratePress **/
add_filter( 'body_class', 'plm_custom_body_class' );
function plm_custom_body_class( $classes ) {
    if ( class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_enabled() ) {
        $classes[] = 'full-width-content';
        $classes[] = 'hide-page-header';
	    return $classes;
    }
    else {
	    return $classes;
    }
}

/** remove page title from actual html **/
add_filter( 'generate_show_title', 'plm_remove_page_title', 20 );
function plm_remove_page_title($output) { 
   if  ( class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_enabled() ) {
        return false;
    }
    else {
        return $output;
    }
}

/** Set page layout to no sidebar **/
add_filter( 'generate_sidebar_layout','plm_custom_sidebar_layout' );
function plm_custom_sidebar_layout( $layout ) {
    if ( class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_enabled() ) {
        return 'no-sidebar';
    }
    else {
 	    return $layout;
    }
}
/* PAGE HEADER */

/* Hide the page header when BB is active on a page */
.hide-page-header .generate-page-header,
.hide-page-header .page-header-image,
.hide-page-header .page-header-image-single {
    display:none;
}

/* Unhide the page header when BB is active but we want to use GP custom page header */
.hide-page-header .generate-page-header.page-header-content,
.hide-page-header .page-header-image.page-header-content,
.hide-page-header .page-header-image-single.page-header-content {
    display:block;
}