Comment on WordPress Page Templates Tutorial by SEO Dave.

WordPress Post Template Doh, when I fixed the code error I mentioned above accidentally reactivated one of the Stallion header areas that should be disabled.

I’ll be changing that particular Stallion Page Template in the next update. It’s really easy to fix, simple case of adding a 0.

Opportunity to explain Page Templates :-)

Stallion Static Page Blank Sales no Sidebars is the file page-sales.php and is based on the page.php file (a WordPress template file for Static Pages).

This Page template has a lot more of the Stallion code directly within it because it doesn’t use as much of the Stallion themes styling for the main content (hence your earlier formatting problem) and shouldn’t have the Stallion header (my mistake fixing a mistake), it’s designed this way so you can build your content outside WordPress/Stallion, but not completely outside.

Most WordPress themes including Stallion use WordPress template files like header.php, footer.php, sidebar.php… these hold the header code, footer code, sidebar code etc… and are ‘loaded’ in a template file like single.php (template file for Blog Posts), page.php (template file for Static Pages) with this code:

<?php get_header(); ?>

Because I wanted full control over the page-sales.php Page Template I didn’t use the normal structure, instead copied the code from header.php, footer.php etc… and copied it directly into page-sales.php where you’d normally find

<?php get_header(); ?>

This means this file includes the header, footer, sidebar code in one file and can be changed outside of what other Stallion template files do.

If you load page-sales.php in a text editor you will see near the top all the header.php file code.

To fix my mistake find

<?php if(st_header_hide()=='1'){ ?>

Change to

<?php if(st_header_hide()=='10'){ ?>

This has the same effect as turning the header area off on the Stallion Layout Options page.

The really useful feature of this Stallion Page Template is I didn’t delete the code I didn’t want to load, I changed the options so they would never load which means it can be easily turned back on by removing a 0.

st_header_hide()==’1′ refers to one of the Stallion options (Stallion Layout : Show Original Stallion Header Area). When the Show Original Stallion Header Area option is ticked st_header_hide option is set to 1 and the code after “if(st_header_hide()==’1′){” is loaded. When the Hide Original Stallion Header Area option is ticked st_header_hide option is set to 0 and the code isn’t loaded.

This is why I set st_header_hide()==’10’, it’s checking (does it equal ==) if the st_header_hide option is set to 10, 10 is never set (only options for this setting is 1 or 0, on or off) and so the header code will never load (can only load when set to 1).

This allows Stallion themes users the option to turn features back on by changing a 00, 10 or a 20 (some options have more than 0 and 1 as options) to a 0, 1 or 2 (basically just added a 0 after features that are disabled).

For example if you wanted the social media links, Twitter, Facebook like etc… there’s two bits of code

<?php if(st_social_network()=='10'){ ?>

and

<?php if(st_social_network()=='20'){ ?>

The first line is when the links are added above the content, the second below. Changing them from 10 and 20 to 1 and 2 re-enables the links.

If you wanted both a Page Template with and without the social media links you can make a new Stallion Page Template.

Make a copy of page-sales.php and call it something like page-sales-plus-social.php (doesn’t matter too much what the ***** of page-*****.php is as long as it’s unique and starts page-

Edit page-sales-plus-social.php and change the st_social_network code from 10 and 20 to 1 and 2. At the top of the file is the name of template, currently:

Template Name: Static Page Blank Sales No Sidebars

Change to

Template Name: Static Page Blank Sales No Sidebars Plus Social Media

Save and upload to your /stallion-seo-theme/ folder or your /stallion-child-example/ folder if you are using a Child theme. Edit the page you want to use the new Page Template on and it will be available.

There’s a file page-example.php which is a copy of page.php ready for Stallion template creation for templates that do use all Stallion features.

This template does use

<?php get_header(); ?>

So is for editing the main content, if you wanted more control you could replace the above with the entire contents of header.php, repeat with the sidebar and footer code.

Unlike other WordPress Themes you can use the Static Page templates on Blog Posts as well by activating “Stallion Layout Options : Custom Templates ON”. This setting also activates templates for Categories as well, the Category template files are categories-*****.php file format, same concept as Page Templates with an additional options page under Appearance >> Category Templates. When set the Page Templates are available for Blog Posts, some like the sitemaps are not suitable for blog Posts and shouldn’t be used for Posts.

David