0

Make templates FSE compliant

Philip 21 hours ago 0

WP is moving towards Full Site Editing and it would be great if the layout builder could be compliant with these kinds of themes.

I made a single change to the code, and it seems to be enough (although I'm not enough into the code to know if more changes are needed or if it breaks anything else - it looks like it works though).

In the default plugin

File includes/class-anwpfl-template.php

Around line 150

Replacing the block here 

if ( array_product( $template_loading_check ) ) {
if ( apply_filters( 'anwpfl/template/load_default_template', true, $post->post_type, $post ) ) {
// Prepare layout
$layout = get_post_meta( $post->ID, '_anwpfl_tmpl_layout', true );
$layout = empty( $layout ) ? '' : ( '-' . sanitize_key( $layout ) );

$this->get_template_part( 'content-' . str_replace( 'anwp_', '', $post->post_type ), $layout );
} else {
do_action( 'anwpfl/template/load_alt_template', $post->post_type, $post );
}

// Disable default content
return '';
}

With this


if ( array_product( $template_loading_check ) ) {
ob_start();

if ( apply_filters( 'anwpfl/template/load_default_template', true, $post->post_type, $post ) ) {
// Prepare layout
$layout = get_post_meta( $post->ID, '_anwpfl_tmpl_layout', true );
$layout = empty( $layout ) ? '' : ( '-' . sanitize_key( $layout ) );

$this->get_template_part( 'content-' . str_replace( 'anwp_', '', $post->post_type ), $layout );
} else {
do_action( 'anwpfl/template/load_alt_template', $post->post_type, $post );
}

return ob_get_clean();
}
return $content;
}

Thank you in advance ☺️