
get_header() and get_footer() from specific WordPress Template Folder
Step One: Create Custom Page Template in your root WordPress theme folder
Instead of adding an additional new custom template file in your WordPress template folder, you can create a new folder with a specific name to serve any custom WordPress Page Templates to assign them to specific Pages in your WordPress website.
I Got a new Land Page in the WordPress Page Templates Folder Like the example below:
page-templates/landing-amp.phpTo get the new custom page template layout available to assign it to your specific page on the website you need to hook the function for this.
Step Two: At the top of your custom page template file add the related function from WordPress Codex
<?php /* Template Name: Landing AMP Projects */;?>
To learn more about how it’s work visit Creating Custom Page Templates for Global Use
Step Three: Create New Folder in your WordPress root Template Folder to serve the new files for get_header() and get_footer() functions
In my example, I create a new folder in my current active WordPress Template folder with the name “lamp“. In the new folder create your custom get_header() and get_footer() files to load on your custom page template. The customized head and footer files are served as template parts and are not necessary to name them with
- header-{custom-name}.php
- footer-{custom-name}.php
Step Four: Create two new files in the “lamp” folder as the example below
- /lamp/header-amp.php
- /lamp/footer-amp.php
Step Five: Open your Custom Page Template from Step One and below the 1st-row code the snippets below
- <?php get_template_part( ‘lamp/header-amp’ );?>
- <?php get_template_part( ‘lamp/footer-amp’ );?>
Recommended Article about the next part of loading the content on those new pages with running the basic Loop and display your WordPress Page Content
- get_the_content()
- and the_content()
- get_the_permalink()
- the_permalink()