I like to think of WordPress as a Web gateway drug development. Who started a lot of people started to use the platform initially just looking for a comfortable (and free) way to create a simple website. After some Google searches and consultations WordPress Codex Alimentarius Commission, it’s done, this should be it. A bit like “I’m just going to try again.”
However, a good chunk of users do not stop there. Instead, they are addictive. To come up with more ideas. experiment. Try the new plug-ins. Find fireflies. prosperity. Soon, there is no turning back. Does this sound like your story? As a WordPress user it is natural to want to your site more and more control. Eager to custom design, custom, custom everything.
Fortunately, WordPress is designed for this. Its flexible structure and architecture fragmented allow anyone to change their site almost anything.
Wherein in the pursuit of full site control of the most important tool is a Web page template. They allow users to significantly change the design and functionality of their website. You want the front page of a custom header? carry out. Another sidebar just for your blog page? no problem. Unique 404 error page? Yes. mine. The guests.
If you want to know how the page template WordPress help you to do this, please read on. But first, some background information.

Link in the WordPress template files

What are we talking about when we talk in the WordPress template background? The short version is that the template file that tells WordPress how to display different types of content.
Longer version: Whenever someone sends a request to view a portion of your site, WordPress platform to figure out what kind of content they want to see how a specific part of your site should render.
For the latter, WordPress will try to use your topic to find the most suitable template file. Which is to determine a set of sequential basis, WordPress template hierarchy structure. As you can see, this looks like below or in this interactive version of the screenshot.


List WordPress template hierarchy template file is familiar with the rankings, to determine which files take precedence over another.
You can use it as a decision tree. When WordPress is trying to decide how to display a given page, it works its way down the template hierarchy until it finds the requested page for the first template file. For example, if someone tries to access the address http://yoursite.com/category/news,WordPress will find the correct template files in this order:

  1. Classification – {} slugs .php: in this case, category news.php
  2. Classification – {ID} .PHP>: If the category number 5, WordPress will try to find a file named category 5.php
  3. category.php
  4. archive.php
  5. The index.php

At the bottom of the hierarchy are the index.php file. It will be used to display it has no name attached to it more specific template file anything. If a higher rank in the hierarchy template file, WordPress will automatically use the file to display the content.

Page template and use LINK

For this page, the standard template is usually aptly named page.php. Unless there is available a more specific template files (such as archive.php archive page), WordPress will use all page.php to render the content pages on your site.
However, in many cases, it may be necessary to change the design, look, feel, or various parts of your website functionality. This is a page template into play. Custom page templates let you personalize any part of your WordPress site without affecting the rest of it.
You may have seen at work this point. For example, many WordPress theme today took an option to change your page, full width, or add a second column switching positions sidebar. If this is your case, it is likely to be completed by the template file. There are several ways to do this, then we went to them.
But first, a word of caution: Because using templates involving your theme editor and modify files, it’s always a good idea to make these types of custom in time to the subtopics. Thus, you do not run when your parents have obtained relating to the risk of changes to update coverage.

How to customize WordPress defined any page

There WordPress using custom page templates are three basic methods: the conditional statement to an existing template; create the hierarchy of rank higher specific page template; template directly to a specific page. We’ll look at these in turn.

Use the default template tag Conditions

A simple way to make change is the use of a specific page of a lot of WordPress conditional tags have been added to the template used. As the name suggests, these tags are used to create a function which is executed only if the conditions are met. In the context of the page template, which will be along the “only perform operations on the page Y. X” line stuff
Under normal circumstances, (unless, of course, you want to customize the different parts of your site), you’ll add a condition code to add to your theme page.php file. They allow you to make limited home, home, change the other pages of the website or blog page.
Here are some common conditions Tags:

  1. is_page (): targeting a specific page. With the page ID, title, or URL / name used.
  2. is_home (): applicable to the home page.
  3. is_front_page (): Settings → setting to read the front page for your site
  4. It is _category (): Condition category page. You can use the ID, title, or URL / name as is_page () mark.
  5. is_single (): single column or accessories
  6. is_archive (): Condition Archived page
  7. is_404 (): only applies to 404 error page

For example, instead of the standard get_header when added to your page.php (); loading the specified custom header file header, shop.php tab, the following code will display the page http://yoursite.com/products.

if ( is_page('products') ) {
  get_header( 'shop' );
} else {

If you have a store on your website, you need to display a different page in the store header image or customize the menu a good use case, it would be. Then, you can add custom headers shop.php these, it will be displayed in an appropriate place. However, the condition is not limited to a tag. You can like this for several statements:

if ( is_page('products') ) {
  get_header( 'shop' );
} elseif ( is_page( 42 ) ) {
  get_header( 'about' );
} else {

In the second example, the situation will change the behavior of two different pages of your site. In addition to the above-described load store-specific header file, which is now a head load a page, about.php and 42 ID for the standard header file for all other pages.
To learn more about the conditions of use of the label, the following resources is strongly recommended:

  • WordPress Codex: Conditional Tags
  • ThemeLab: The Ultimate Guide to WordPress conditional tags

Creating pages in WordPress specific file hierarchy

Conditional tags are a great way to introduce change your page template smaller. Of course, you can also use one of the other conditions after several statements to create custom large. I find this a very cumbersome solution, however, you will select the specified template file instead.
One way to do this is to use WordPress template hierarchy. As we have seen, the level iterates through the list of possible template file, then select the first one to find suitable. For page hierarchy is as follows:

  • Custom Page Templates
  • Page-level {} slugs .php
  • Page level (number) of .php
  • page.php
  • The index.php

Topping the list is assigned directly to a specific page custom page templates. If one exists, WordPress will no matter which other template file exists using it. We’ll talk about a little bit more custom page templates.
After this, WordPress looks including relevant web page template plug. For example, if you include in the file named page about.php theme file, WordPress will use this file to display your “About” page or any page can be found at http://www.yoursite.com/about.
Alternatively, you can also be achieved by targeting your page ID. Therefore, if you have ID 5 in the same page, WordPress will file if the template page before using 5.php page.php existence; that is, only when a higher level not available for page templates.
(BTW, you can hover in the background under your WordPress “all pages” to find out the title of each page ID. The ID will appear on the link your browser to display.)

ASSIGNING custom page templates

In addition to the form, WordPress will automatically use the templates provided, you can manually specify a custom template to a specific page. As you can from the hierarchy of the template, which will be better than any other template files appear to see in theme folder.
Create a template as a specific page in WordPress level, which requires you to provide a template file, and then link it to any page you want to use it. The latter can be in two different ways, you may already be familiar to complete. In case you’re not, here’s how to do it.

1. Assign custom page template from the WordPress editor

In the WordPress editor, you will find the so-called “Page Properties” under the “Template” drop-down menu, select an option field.


Click on it to give you your WordPress website page template list. Choose one of your desire to save or update the page and you are done.


2. Set up a custom template to quickly edit

The same may not enter the WordPress editor to achieve. Go to the “all pages” and any item in the list will hover there. A menu will become visible, including the “Quick Edit” item.
Click on the list it can be set directly from the edit page. You’ll see the same drop-down menu to select a different page templates. Select one, and you do update the page.
Not so hard after all, is not it? However, if you do not have a custom page template? Make your site look exactly the way you want How do you create it? Do not worry, that’s the next part is all about.

A step by step guide to create a custom page templates

Custom template file for your web page put together is not difficult, but here you have to pay attention to some details. So let us in the process bit by bit.

1. Locate the default template link

A good way is by copying its current use is that you want to edit the page template begins. It is easier to modify existing code, rather than starting from scratch to write the whole page. In most cases, this will be the page.php file.
(If you do not know how to find out which file is the template you want to edit, plug what documents will prove to be useful to use the page.)
I will use twenty-two theme presentation. Here’s how it looks like a standard web page templates:

As you can see, nothing too fancy here: headers and footers, and call in the middle of the loop. The pages in question looks like this:


2. Copy and rename the template file

After identifying the default template file, it’s time to make a copy. We will use the copied file, so that we needed to change the page. To this end, we must also be renamed. Can not have two files with the same name, it’s just confusing everyone.
You are free to give the file you like, as long as it does not start with any topic reserved filenames any name. So, do not name it something.php page or anything else that will make WordPress is that it is a special template file.
It makes sense to use it to easily identify what is the use of a template file, such as the name of my custom -template.php file. For my part, I will go full custom width.php.

3. Customize the template header

Next, we want to tell the WordPress, the new file is a custom page template. To this end, we will have to adjust the file header following ways:

 * Template Name: Custom Full Width
 * Description: Page template without sidebar

// Additional code goes here...

In the “Template Name” is the name to be displayed in accordance with the WordPress editor “page properties” what will be. Be sure to adjust it to your template name.

4. Custom Code

Now is the time to go to the meat and potatoes of the page template: Code. In my case, I just want to clear the sidebar from my demo page.
? It is easier because all I need to do is delete <PHP get_sidebar ();? > From my page template, because this is being called sidebar. So my final custom template looks like this:

5. Upload page template

Saved my custom file, it is time to upload it to my site. Custom page templates can be saved in several places by WordPress recognized:

 * Template Name: Custom Full Width
 * Description: Page template without sidebar

get_header(); ?>

<div id="primary" class="site-content">
  <div id="content" role="main">

    <?php while ( have_posts() ) : the_post(); ?>
      <?php get_template_part( 'content', 'page' ); ?>
      <?php comments_template( '', true ); ?>
    <?php endwhile; // end of the loop. ?>

  </div><!-- #content -->
</div><!-- #primary -->

<?php get_footer(); ?>

6. Activate template link

As a last step, you need to activate the page template. As I mentioned earlier, which is based on property pages in WordPress Editor → Templates. Save, view the page everything will be fine! This is not my custom sidebar page:


Not difficult, is it? Do not worry, you’ll soon get the hang of it. To give you a template of what use these pages, I’ll show more use cases (including code) for the remaining a better impression of this article.