WebDevStudios / WDS-Simple-Page-Builder

Uses existing template parts in the currently-active theme to build a customized page with rearrangeable elements.
GNU General Public License v2.0
136 stars 25 forks source link

Hide page builder on specific page templates #76

Open koskinenaa opened 6 years ago

koskinenaa commented 6 years ago

Hi,

This might be a dumb question, but I just can't figure out how to solve this.

I have couple special page templates and I'd like to use the default WP editor with them and not show the page builder. I already managed to limit the visibility of the default editor to these special page templates, but I can't get rid of the page builder metabox on these templates.

The code below I came up with kind of does the trick on the edit view. But it breaks the template part saving on the edit view and also the wds_page_builder_area() function on the front end - no template parts show up.

`function wpfm_register_page_builder_areas() {

if ( isset( $_GET["post"] ) ) {
  $post_id = $_GET["post"];
}

if ( !isset( $post_id ) ) {
  return;
}

$page_template = get_post_meta( $post_id, '_wp_page_template', true );

$hide_builder = array(
  'templates/template-event-page.php',
  'templates/template-event-registration-page.php',
  'templates/template-event-thank-you-page.php',
  'templates/template-form-page.php'
);

if (  in_array( $page_template, $hide_builder ) ) {
  return;
}

register_page_builder_area( 'content' );

} add_action( 'after_setup_theme', 'wpfm_register_page_builder_areas' );`

Surely there must be a better way to limit the page builder visibility based on the page template, isn't there?