Template Hierarchy In WordPress

WordPress uses the query string to decide which template or set of templates should be used to display the page first according to the user's request. This mechanism is called template hierarchy in WordPress. The query string is a piece of information that is contained in the link to each part of your website.

Put simply, WordPress searches down through the template hierarchy until it finds a matching template file. To determine which template file to use, WordPress:

  1. Matches every query string to decide which page is being requested (for example, a search page, a category page, etc);
  2. Selects the template in the order determined by the template hierarchy;
  3. Looks for template files with specific names in the current theme’s directory.

 

By default, WordPress sets the site’s home page for the display of our latest blog posts. If home.php does not exist, WordPress will call index.php.

 

Remember: If front-page.php exists, it will override the home.php template.

 

Read the details about template hierarchy in WordPress from this link.

 

#wordpress