Overriding a template from your theme
Copy a template into your theme and it wins. Where each kind is looked for, and which folder to use for new work.
- Advanced
- 6 min read
- Applies to 2.0
The idea
Templates ship inside the plugin. Put a file with the same name in the right folder of your theme and yours is used instead — the plugin's copy is left alone, so an update cannot overwrite your work.
Thirty-one templates can be overridden this way.
Email templates
Put email overrides in attributes/front/emails/ in your theme. That is the
folder to use for new work.
your-theme/
└── attributes/
└── front/
└── emails/
├── branded.php
├── enhanced.php
├── default.php
└── plain.php
Older locations still work — attributes/emails/ and two legacy aliases are
searched after the folder above — so a theme built against an earlier convention
keeps working after an update. New work should use the first one.
Coming from version 1.x? There were two conventions and each was honoured by
only half the code: a branded.php in attributes/emails/ applied to
registration, reset and two-factor mail, but not to lost-password mail or the
admin preview, which looked in attributes/front/emails/. If you have an
override that seemed to apply inconsistently, that is why. Both paths now feed
one lookup, so a single copy covers everything.
Adding a location of your own:
add_filter( 'attrua_pro_email_template_paths', function ( array $paths ) {
array_unshift( $paths, 'my-plugin/emails/' );
return $paths;
} );
Paths are searched in order, first match wins.
Maintenance page
your-theme/attributes/front/maintenance/
Form and widget templates
your-theme/attrua/registration/
your-theme/attrua/…-widget/
Working on an override
- Copy, do not write from scratch. Start from the plugin's file so you inherit the variables it expects to have.
- Keep the variables. A template is handed its data by the plugin; renaming or dropping a variable breaks it quietly.
- Check after an update. If the plugin's version of a template gains something, your copy will not have it — overriding opts you out of those improvements as well as the unwanted ones.
Override the smallest thing that solves your problem. Much of what people reach for a template override to do — colours, logo, footer text, social links — is a setting on the Emails tab, and a setting survives updates without any of the above.
Something missing or out of date? Tell support.