Testing header stuff


All WordPress themes have a file called page.php. This is your template file for all pages you have on your blog (remember, pages are distinctly different than posts). The page.php file is your default page template. To create a new one, just open that file in any text editor then “save as” a different file name. In my case, I named the template for my sales page signup_page.php.

Now, at the very top of this new file, you’re going to want a block of PHP code as follows:

<?php
/*
Template Name: [your page name here]
*/
?>

This is a PHP comment. Leave the “Template Name:” in place, but you need to change the name of the page. Once you have done that, upload this new file to your blog theme’s folder.

Then, in WordPress, when you go to add or edit a page, scroll way down and you’ll see a setting for “Page Template”. You should see your new page template listed in the dropdown, using the name you entered above. To the right, you can see what my dropdown list looks like in my own WordPress admin panel. I have many different custom page templates in my system, all for different purposes.

 

Custom get_ calls for custom files

A little known ability of the get_ functions is that you can use them to call custom header, sidebar and footer files. It’s a simple two-step process. I’ll use header.php as an example:

  1. Create a new file called header-custom.php
  2. In the template file from which you want to call the new custom header file add ‘custom’ as a variable to the regular get_header() function like below
<?php get_header('custom'); ?>

Now WordPress will use header-custom.php instead of header.php. The exact same method goes for sidebar.php and footer.php as well.