# Plugin Template not being overwritten in Sage 9

**URL:** https://discourse.roots.io/t/plugin-template-not-being-overwritten-in-sage-9/12455
**Category:** sage
**Created:** 2018-05-13T18:49:45Z
**Posts:** 6

## Post 1 by @s3w47m88 — 2018-05-13T18:49:45Z

I’m using Sage 9. I have read through the documentation for Sage 9 many times now, as well as begun Laravel and Blade training through Laracasts. But am experiencing an issue where I cannot override a Theme Template that is being used by a Plugin.

I have a Plugin installed called ‘WP Hotel Booking’ and it states I can override the Single Room template by placing it in sage/tp-hotel-booking/single-room.php

I have tried this, also tried moving it into resources/views/ and also tried renaming it to single-room.blade.php and putting only `<h1>Test</h1>` in the file contents. It remains completely ignored.

I am unable to decipher whether this is a problem with the Plugin or related to Blade somehow. Can anyone explain how you go about identifying this?

---

## Post 2 by @mmirus — 2018-05-14T22:02:52Z

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.

---

## Post 3 by @marcelo2605 — 2018-05-16T12:59:27Z

I’m following this solution to Theme My Login plugin templates.

I start converting file to blade format but I stop in an error:

The original:

```
<div class="tml tml-login" id="theme-my-login<?php $template->the_instance(); ?>">
	<?php $template->the_action_template_message( 'login' ); ?>
	<?php $template->the_errors(); ?>
```

Blade format:

```
<div class="tml tml-login" id="theme-my-login@php $template->the_instance() @endphp">
	@php $template->the_action_template_message( 'login' ) @endphp
	@php $template->the_errors() @endphp
```

Error:

> Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function the\_action\_template\_message() on null in /srv/www/website/public\_html/wp-content/uploads/cache/00f3f37a810a747360a78716d6edd577d9db6c08.php:3

---

## Post 4 by @mmirus — 2018-05-22T21:16:50Z

Sorry @marcelo2605, didn’t see your question until now.

In theory, where is `$template` being set? That error indicates that it’s not defined (it’s null).

---

## Post 5 by @marcelo2605 — 2018-05-28T20:23:01Z

No problem @mmirus. I fixed the problem adding a theme-my-login folder inside resources folder. Inside, I add the TML templates files.

Found this solution here: [https://wordpress.org/support/topic/custom-login-template-with-sage-9-theme/](https://wordpress.org/support/topic/custom-login-template-with-sage-9-theme/)

---

## Post 6 by @vibcruz — 2018-07-04T13:19:55Z

That was the best and short explanation about overwritte templates files in Sage 9.
