Create/Modify a default page template without having to exclude all the other pages

Hey @JohnF,

if I understand your scenario correctly you can use the bricks/active_templates hook. In your case it should look something like this:

add_filter( 'bricks/active_templates', function( $active_templates, $post_id, $content_type ) {
    if ( ! bricks_is_frontend() ) {
        return $active_templates;
    }

    if ( $content_type !== 'content' ) {
        return $active_templates;
    }

    $post_type = get_post_type( $post_id );

    if ( $post_type !== 'page' ) {
        return $active_templates;
    }

    $bricks_data = \Bricks\Database::get_data( $post_id, 'content' );

    if ( empty( $bricks_data ) ) {
        return $active_templates;
    }

    $active_templates['content'] = $post_id;

    return $active_templates;
}, 10, 3 );

This makes sure that pages do not use the configured page template if they are built with Bricks themselves.

Let me know if it helps.

Best,

André

2 Likes