Templates work in tandem with the database and PHP to render HTML files at runtime. As explained in the themes video (from the prior section), templates get merged with content from the database in a fraction of a second, and are a convenient way to organize layout and style in a generic way, without having to write code to display every page in your site.
Below, we provide an overview of the most common WordPress templates, written by Himanshu Sharma, and found here: https://www.optimizesmart.com/wordpress-ninja-15-minutes/. Each of these templates can be edited by going to your WordPress Admin Panel >> Appearance >> Editor, and then selecting the template of interest from the right-hand panel.
This file display headers and navigation. If you want to make changes to the head section(… of each web page (like adding the Google Analytics Tracking Code or other tracking code etc) then you need to edit this file.
This template file is used to display the blog post index. The blog post index contains a loop (bunch of PHP code) which displays the most recent blog posts according to some predefined conditions. It displays a list of posts in excerpt or full-length form. The blog post index can be set to display on the front page of your website or on a separate static page.
This template file can also be used to display the blog post index. The blog post index can be set to display on the front page of your website or on a separate static page. If this file is missing then wordpress looks for a file called index.php in the active theme’s directory & uses that template to display the blog post index.
This template file displays your website’s front Page (which is usually called the home page). The front page can be a static page or a blog posts index. WordPress searches for this file first when you load the front page of your wordpress website. If this file is missing then wordpress looks for a file called home.php. If home.php is also missing then wordpress looks for a file called index.php and uses that template to display the front page of your website.
This template file displays page title and its contents. If you are a logged in user with ‘edit’ permission than this file displays the ‘Edit’ link through which you can edit the contents of a page. It also display comment list and comment form.
The template file displays:
- blog post’s title
- blog post’s content
- author name
- date of the post
- post category & tags
- comment list
- comment form
- Navigation links to the previous and next posts.
This template file controls how category pages should be displayed. You can edit the file by going to your WordPress Admin Panel > Appearance > Editor > category.php
This template file controls how an author page should be displayed. You can edit the file by going to your WordPress Admin Panel > Appearance > Editor > author.php
This template file controls how a search result page should be displayed .
This template file is used when wordpress cannot find the post or page which is queried.
This template file decides how the comments should be displayed.
This is the main style sheet file of your wordpress theme and is used to control the design and layout of your web pages. You can also edit this file to change the theme name, author name or author URL.
This template file is used to control the sidebar display. You can set up the contents of the sidebar widgets through the WordPress admin panel.
This file is used to add your own custom features to your theme. It works like a plug-in file. Since this file is theme specific, you lose the custom functionality once you change your theme. Not all wordpress themes use this file.