Theme author templates

Theme authors can make their templates available to users within the lite and premium version of Beaver Builder without needing to import them through the WordPress importer. This is perfect for theme authors who distribute Beaver Builder using TGM plugin activation, and it's a great addition for those already building custom modules for their themes.

Using the following method, templates are automatically made available in Page Builder’s template selector after you register them.

1. Choose where your templates will live

We recommend that you keep a copy of your templates on a source site for a better user experience. When a user selects a template for use, the media files in the template (such as images and videos) are not imported to their WordPress site but rather are linked to your source site. This is because users often don't want to import sample images that they will not be using.

For example, all of our templates live on a multisite instance at demos.wpbeaverbuilder.com. We also use this location for demos on our own website.

If you don’t keep a copy of your templates on the source site, users can still use your templates, but the media will not be loaded.

2. Create your templates

Create your custom templates and saved rows or modules and save them in your source location. See the Related Links for information about how to enable the Templates admin panel and work with templates and saved rows and modules.

3. Order, categorize and add featured images

Use the Templates admin panel to adjust the order in which your templates and saved rows and modules appear, assign categories, and add featured images. See the Related Links for details.

4. Export your template data file

  1. In the WordPress admin panel, click Tools > Template exporter
    If you don't see that menu option, enable it by going to  Settings > Page Builder > Templates and selecting the Template Data Exporter checkbox.
    You’ll see a screen similar to the screenshot below.
  2. Select the templates for export and click Export template data. A templates.dat file will download to your computer.

5. Register your templates

Register the templates.dat file with Beaver Builder, using the FLBuilder::register_templates method within either a theme or plugin, as shown in the example below. 

The biggest consideration in deciding whether to register within the theme or in a plugin is whether you want the templates to remain accessible when the user switches to a different theme. If the answer is yes, register in a plugin. If no, register within a theme. If you choose a plugin, you can  download an example plugin to use as a model.

To register your theme:

Pass the full path of your templates.dat file to the FLBuilder::register_templates method:

FLBuilder::register_templates( '/path/to/your/templates.dat' );

In order to make sure that your theme or plugin doesn’t throw any errors, hook that method into the after_setup_theme action, and check to see if the builder is installed and the current version supports registering templates, as follows.

function my_plugin_load_bb_templates() {
    
    if ( ! class_exists( 'FLBuilder' ) || ! method_exists( 'FLBuilder', 'register_templates' ) ) {
        return;
    }
    
    FLBuilder::register_templates( '/path/to/your/templates.dat' );
}

add_action( 'after_setup_theme', 'my_plugin_load_bb_templates' );

The templates will be loaded the next time you launch Page Builder.

6. Install and test your plugin or theme

Make sure your plugin (or theme) is installed and active and then head on over to a page and launch Page Builder. If you got everything right, your templates should show up in one of three places based on whether they are layouts, rows, or modules.

Layouts will show up in the template selector within the category you specified, or Uncategorized if none. They can be accessed from the category select in the top right of the template selector as shown below.

For rows and modules, new sections will be created in Page Builder’s Add Content panel, based on the categories you specified (or Uncategorized, if none), as shown below.

Things to keep in mind

Here are a few things to keep in mind when building templates for Page Builder. 

Templates can only be created in the premium versions

The ability to create, save, edit and export templates is currently only available in the premium versions of Beaver Builder. You will need at least the Standard subscription to export templates.dat files.

Not all modules are available in the Lite version of Beaver Builder

If you build templates for the Lite version, keep in mind that not all of our modules are available there. If users use a template with a module that is not supported in their version of Beaver Builder, the module will not be rendered.

For this reason, we recommend third-party theme authors create custom modules for their themes and templates, if they need something that isn’t available in the lite version. See the Related Articles for information about how to create custom modules.

Global rows and modules are exported as standard templates

Global rows and modules are exported to  templates.dat as standard (non-global) rows or modules. 

That’s it!

As always, feel free to get in touch if you have any questions or run into any issues.