Add a Singular theme layout to the WordPress Page Template field

Singular-type theme layouts that you create in Theme Builder 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 theme 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 theme 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 Theme Builder.
  • You are using a child theme, so your changes won't get overwritten with theme updates.

To add a Theme Builder Singular theme layout to the Template field of all Pages and Posts:

  1. Get the ID of the Theme Builder Singular theme 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.
  2. 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:
    page_test_singular.php
    Note: Do not use page- with a hyphen, use page_ with an underscore.
  3. 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 );
  1. In the third line, replace Test Singular with the term you want to appear in the Template dropdown list. 
  2. 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.
  3. In the last line, replace 88 with the ID number of your Singular theme layout.
  4. Save the file and place it in the following location on your WordPress site:
    site-root/wp-content/themes/bb-theme-child/

Open a page or post for editing and check for the name of your layout in the Template dropdown list.