Add a Singular Themer layout to the WordPress Page Template field
Singular-type Themer layouts that you create in Beaver Themer do not by default appear in the Template dropdown list on Page or Post editing screens. However, you can treat them like other WordPress page templates and add them to the Template dropdown list with a bit of PHP code. You can add the choice to Pages only, Posts only, or both.
In this example, we'll add a Singular Themer layout to the Template field for both Posts and Pages, as shown in the following screenshot.
Note: The name in the Template field dropdown list comes from the information you add to a file in the following procedure. The Themer layout is related by its ID, not by its title.
This procedure has the following requirements:
- The Beaver Themer plugin is installed and activated.
- You have created a Singular-type layout in Beaver Themer.
- You are using a child theme, so your changes won't get overwritten with theme updates.
To add a Beaver Themer Singular Themer layout to the Template field of all Pages and Posts:
- Get the ID of the Beaver Themer Singular Themer layout that you want to use.
On the WordPress admin panel, click Builder, then click Edit for the Singular layout that you want to use. The ID is the number displayed in the URL when the layout is open for editing.
- In a text editor, create a file that will hold the code for the custom page template. Just to help us remember the purpose of that custom file, we'll follow the WordPress global template naming suggestion and use
page_followed by the template name we want to use:
Note: Do not use
page-with a hyphen, use
page_with an underscore.
- Paste the following code into the file.
<?php /* Template Name: Test Singular Template Post Type: page, post */ //Substitute your own page ID in the following line FLThemeBuilderLayoutRenderer::render_all( 88 );
- In the third line, replace
Test Singularwith the term you want to appear in the Template dropdown list.
- In the fourth line, leave as is for the template name to appear for both Pages and Posts, or leave one and delete the other if you want it to apply selectively to Pages or Posts.
- In the last line, replace
88with the ID number of your Singular Themer layout.
- Save the file and place it in the following location on your WordPress site:
Open a page or post for editing and check for the name of your layout in the Template dropdown list.