Template Files You May Want to Use For Your Twenty Fifteen WordPress Site - dummies

Template Files You May Want to Use For Your Twenty Fifteen WordPress Site

By Lisa Sabin-Wilson

To make your website work properly, WordPress uses all the theme files together. Some, such as the header and footer, are used on every page. Others, such as the Comments template (comments.php), are used only at specific times, to pull in specific functions. When someone visits your site, WordPress uses a series of queries to determine which templates to use.

You can include many more templates in your theme. Here are some of the other template files you may want to use:

  • Comments template (comments.php): The Comments template is required if you plan to host comments on your blog; it provides all the template tags you need to display those comments. The template tag used to call the comments into the template is <?php comments_template(); ?>.

  • Single Post template (single.php): When your visitors click the title or permalink of a post you’ve published, they’re taken to that post’s individual page. There, they can read the entire post, and if you have comments enabled, they see the comments form and can leave comments.

  • Page template (page.php): You can use a Page template for static pages in your WordPress site.

  • Search Results template (search.php): You can use this template to create a custom display of search results. When someone uses the search feature to search your site for specific keywords, this template formats the return of those results.

  • 404 template (404.php): Use this template to create a custom 404 page, which is the page visitors get when the browser can’t find the page requested and returns that ugly 404 Page Cannot Be Found error.

These templates are optional. If these templates don’t exist in your WordPress themes folder, nothing breaks. The Main Index template handles the display of these items (the single post page, the search results page, and so on). The only exception is the Comments template. If you want to display comments on your site, you must have that template included in your theme.