Custom Page template placement

I have created a couple of custom page templates, but having difficulting making them available in the page editor using info found in your support forums:

Version: Pro 1.2.3
Stack: Integrity
Active Theme: Pro-child
Template file contents:

<?php

// =============================================================================
// TEMPLATE NAME: CustomTest
// -----------------------------------------------------------------------------
?>

<?php x_get_view( x_get_stack(), 'template', 'layout-content-sidebar' ); ?>

I have found references online that indicate that custom page templates need to be in /wp-content/themes/pro-child/views/integrity/* (mirror dir structure of /wp-content/themes/pro/views/integrity, which is where the default templates reside). But I have also found references stating that the custom templates go in the child theme root (/wp-content/themes/pro-child/). I have tried both, and neither is working (ie new template is not listed in the editor).

Permissions on all files and dir are the same as the default template directory. I have done this numerous times in other themes, never an issue.

Please advise.

Hi there,

Here how you should add a template. For example, we are creating a page template called hello.

At the root level of your Child theme add a new file called template-hello.php. Copy the code of the template-blank-1.php at the root of the theme and paste it in the file, Then do proper changes for the template including the name of the template at the top of the file and the name of the file which will be retrieved later:

<?php

// =============================================================================
// TEMPLATE NAME: hello
// -----------------------------------------------------------------------------
// A blank page for creating unique layouts.
//
// Content is output based on which Stack has been selected in the Customizer.
// To view and/or edit the markup of your Stack's index, first go to "views"
// inside the "framework" subdirectory. Once inside, find your Stack's folder
// and look for a file called "template-blank-1.php," where you'll be able to
// find the appropriate output.
// =============================================================================

?>

<?php x_get_view( x_get_stack(), 'template', 'hello' ); ?>

<?php x_get_view( x_get_stack(), 'template', 'hello' ); ?> means that you need to search for a file called template-hello.php in /framework/views/{Name of the Stack}/

Then add a new file in: wp-content/themes/x-child/framework/views/integrity/template-hello.php I assumed that you are using the Integrity stack, if not you can change the folder name to the proper stack name.

You will need to create all the folders in the Child Theme.

Now copy the content of the template-blank1.php inside the framework/views/integrity folder and paste it in the newly added file:

<?php

// =============================================================================
// VIEWS/INTEGRITY/TEMPLATE-BLANK-1.PHP (Container | Header, Footer)
// -----------------------------------------------------------------------------
// A blank page for creating unique layouts.
// =============================================================================

?>

<?php get_header(); ?>

  <div class="x-container max width offset">
    <div class="x-main full" role="main">

      <?php while ( have_posts() ) : the_post(); ?>

        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
          <div class="entry-wrap">
            <?php x_get_view( 'global', '_content', 'the-content' ); ?>
          </div>
        </article>

      <?php endwhile; ?>

    </div>
  </div>

<?php get_footer(); ?>

Now check the dashboard:

You can use whatever template that you want as the starting point of your page template. So instead of template-blank-1.php you can use template-blank-2.php for example.

Thank you.

1 Like

This worked perfectly – thanks!

You’re welcome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.