Add Structural Variation With WordPress Custom Page Templates
Page templates in WordPress are one of the greatest inventions to add highly customized functions or structural variations to your website. Newcomers and novices can go with these as they are very easy to create. They are rich in potential and even seasoned professional will find it hard to explore all the features.
Copy the popular page themes such as the default theme of WordPress Twenty Fourteen and tweaking and get started instantly. You also have the provision to add your own styles and Java scripting with ease.
What do we understand by Page Template?
With a page template you can deviate from the existing structure of your site and add new, exciting features. Twenty Fourteen have 2 great examples: a full-width page and one contributor page. The full -width template changes the format of the page by eliminating the side bars, putting more focus on the content.
Twenty Eleven also has 2 page templates – the sidebar template and the showcase template. You will get good sidebar on your page by selecting sidebar template. The showcase page first shows the sticky posts and then series of recent posts.
There are premium themes like adding several page templates to existing themes in order to create pixel – perfect forms, customizable author lists, bespoke post listings and much more.
Template Hierarchy In WordPress
The template hierarchy is a series of template files with which WordPress is familiar. These files are ranked to decide which one takes preference over another. It will be easier if website developers consider it as a decision tree. When WordPress decides how to exhibit a given page, it works its way to the template hierarchy till it unearths the 1st template file that matches the requested page.
At the end of the hierarchy is index.php. It can be used to exhibit any content which is not having any precise template file linked to its name. WordPress will automatically make use of a template file which has higher ranks in the hierarchy, to exhibit the content.
Conditional tags usage in Default templates
WordPress has many conditional tags which can be added in order to make page-specific changes easily. As per the names, these tags can create functions that can be performed only if specific conditions are met. While considering page template, this will be the – ‘Only execute action X on page Z’. Usually, you add conditional tags to your existing theme page.php file, save you wish to customize different sections of your website. They allow you to make alterations restricted to the front page, home page, blog page or other pages in your site. Here is a list of some conditional tags used often:
- is_page(): this is used to target a particular page and can be used with page title, ID or URL/name.
- is_front_page(): aims your site’s front page as set in Settings – Reading
- is_home(): this is used to modify the home page.
- is_single(): used for single attachments or posts
- is_archive(): used for archive pages
- is_404(): this is used to target only the 404 error pages.
- is _category(): targets category page and can use title, ID, name/URL like
- is_page() tag.
Besides, you can manually disperse custom templates to particular pages for providing templates in structures that WordPress will use automatically. As you can note from the template hierarchy, these will surpass other template files existing in the theme folder. Just like the way you create page-specific templates for the hierarchy of WordPress, you are required to provide a template file and next, you can link it to any page you wish to use it for.
Leave a Reply