Plugin Template not being overwritten in Sage 9

Hey @s3w47m88 - out of the box, the file resources/wp-hotel-booking/single-room.php should override the plugin template.

To get it more neatly integrated into the Sage file organization and Blade, add this to app/filters.php:

add_filter('template_include', function ($template) {
    if (is_single() && get_post_type() == 'hb_room') {
        $blade_template = locate_template('single-room.blade.php');

        return ($blade_template) ? $blade_template : $template;
    }

    return $template;
}, 100);

And put your custom template in resources/views/single-room.blade.php.

You can modify that filter as needed if you want to use a different folder or change anything else.

Same approach should work for the plugin’s other templates if you want to override more.

8 Likes