What Are Templates In WordPress?

WordPress Templates are those files which control how your WordPress site will be displayed on the Web. These files draw information from your WordPress MySQL database and generate the HTML code which is then sent to the web browser.

By its powerful theme system, WordPress furthermore allows you to define as few or as many Templates as you like all under one theme. Each of these Template files can be configured for use under some specific situations.

On in simple words, A template in WordPress is a layout which is only for certain pages. In most of the WordPress themes, you can find files single.php or archive.php – template for single post view and for archive view similarly. This structure, as a result, makes all that views look completely different.

Most importantly, except for these default WordPress templates, there are special templates only for certain pages. They are the separate files that can be applied to every page in WordPress. You can use them by selecting the template you desire when you are editing page:


Uses of  a Template

  • For certain pages where you need a completely different look.
  • You just simply want to display left and right sidebar when a theme has probably only one sidebar.
  • Keep note that you can’t just install template like a theme in a dashboard.
  • A template is a part of a theme and if you need to add a new template to an existing theme, you can only do it by using coding languages i.e HTML, CSS and PHP.

Example: header.php is a default template, therefore, it is used in most WordPress themes. It defines the header area of web pages which is generated or created by WordPress. The header file will be loaded on every page of your WordPress site allowing changes to be made to a single file, so that will apply all over the website.

Applying a WordPress page template

  1. To add a WordPress page template to a page. Go to the Page menu in the WordPress Dashboard and edit or add a new page.
  2. Look for the Page Attributes section. Here in this section, you’ll see a drop-down list for available page templates.

Depending on your WordPress theme, you can select your specific page template options from the drop-down menu.

Previewing and Publishing your WordPress Page Template

To test out how each of these templates would bring out the change in the look of your page, hence select a page template. Now, certainly, you can preview the changes in your page and likewise decide whether or not to apply this page template to the page.

After selection of the page template, click Publish

Probably most of the WordPress themes have some default templates with code for generating HTML output for precise sections of a website.

  1. Main – index.php. For displaying the main page of a website.
  2. Header – header.php. It displays the header section.
  3. Sidebar – sidebar.php. Generates or creates HTML output for the sidebar section.
  4. Footer – footer.php. It displays the footer section.
  5. Theme Functionsfunctions.php. Contains code and functions of the theme.
  6. Single Post – single.php. Displays the single post page.
  7. Comments – comments.php. It displays comments and comment form.

To know more 

Leave a Reply