I’m using beaver builder (a page builder plugin) which has mostly been fine. But there’s one situation in which beaver builder loads page.php directly - without base.php ever being called. And so, in that situation the page obviously isn’t being setup correctly.
This is getting beyond my understanding of WordPress - so apologies if I’m not describing this correctly. But here’s what I’ve been able to trace.
The plugin calls:
$page = locate_template( array( ‘page.php’ ) );
locate_template() (a core wordpress function) returns the full path to page.php
And then page.php gets loaded without base.php ever loading
My theme is based off of version 9 (I believe alpha 4 - I don’t have any of the blade stuff)
Is there any way I can somehow bypass or detect this to push it through base.php instead? Without having to modify wordpress core (locate_template() is in wordpress core) or the plugin?
Ack! Sorry I didn’t get the email showing that you’d responded, will double check my settings.
The plugin is calling locate_template( array( ‘page.php’ ) );
– which is a core WordPress function that returns the full path to page.php
So then page.php gets loaded without base.php ever loading
As far as I can tell, sage’s code is never even being called in this execution. Is there a way for me to get a stacktrace of what functions are called?
I’m not sure what the correct behavior should be, ie…,
is it wrong that they’re calling locate_template on page.php directly? OR
is it wrong that sage isn’t able to intercept that call to route it to base.php?
Working on a new website where this is actually causing a real problem so thought I’d bump - any ideas what else I can try to get this to work? Thanks so much!!
Ok, I think I’ve finally got it working right. Here’s what I’ve got in case anyone else is having this same issue with Beaver Builder.
function isTemplateBuilderPage(){
global $post;
return ( $post && $post->post_type == 'fl-builder-template' );
}
add_filter( 'template_include', function( $main ){
if( isTemplateBuilderPage() ){
// force page builder for templates to go through Sage's base template
return ( ( new Template( new Wrapper( $main ) ) )->layout() );
}
return $main;
}, 1000 ); // 1000 to come after/override page builder functionality
Note that I’m not using fl_builder_template_path filter.