Name Update Time
Netflix September 14, 2024 10:30 am
Disney+ September 10, 2024 10:09 am
Max September 14, 2024 10:20 am
ChatGPT 4 September 14, 2024 2:26 pm
Spotify September 14, 2024 2:08 pm
Prime Video September 14, 2024 2:22 pm
Codecademy September 14, 2024 2:13 pm
Grammarly September 14, 2024 4:45 pm
Canva Pro September 12, 2024 2:24 pm
Udemy Premium Cookies September 2, 2024 2:53 pm

Theme file composition

Before you start making a WordPress theme, you must first understand what files the WordPress theme is made of, and you must know how the WordPress program is connected to the theme file.

The following are all the template files in the default folder of the WordPress default theme. After looking at the picture below, you may still be confused about what these files are for. WordPress themes are written in PHP, not pure HTML + CSS, so the suffix of the template file is .php. If you want to master WordPress theme production and perfectly control your blog, it is best to be familiar with PHP programming. What if you don’t know PHP programming? Can’t you make a WordPress theme? That’s not the case. At least after reading this series of tutorials, you can also master the basic WordPress theme production methods.

The following is the WordPress theme file hierarchy, which will tell you: When WordPress displays a specific page type, which template file will be used? Only by understanding the following theme hierarchy can you know which files you need to write for your WordPress theme.

How to read the following file hierarchy?

Take the homepage as an example. There are two files, home.php and index.php. The WordPress program will search for these two files in your theme folder in turn:

If home.php is found, use home.php as the blog homepage template, even if there is index.php in your theme folder;
If home.php is not found, use index.php as the homepage template;
If neither home.php nor index.php can be found, your theme will not be recognized by WordPress, which is equivalent to waste.
Home page

home.php
index.php
Post page

single-{post_type}.php – If the post type is videos, WordPress will look for
single-videos.php (supported by WordPress 3.0 and above)
single.php
index.php
Page

Custom template – Where you create a page in the WordPress backend, you can select a custom template for the page in the right sidebar
page-{slug}.php – If the slug of the page is news, WordPress will look for page-news.php (supported by WordPress 2.9 and above)
page-{id}.php – If the page ID is 6, WordPress will look for page-6.php
page.php
index.php
Category

category-{slug}.php – If the slug of the category is news, WordPress will look for category-news.php (supported by WordPress 2.9 and above)
category-{id}.php – If the category ID is 6, WordPress will look for category-6.php
category.php
archive.php
index.php
Tag

tag-{slug}.php – If the tag abbreviation is sometag, WordPress will look for tag-sometag.php
tag-{id}.php – If the tag ID is 6, WordPress will look for tag-6.php (supported by WordPress 2.9 and above)
tag.php
archive.php
index.php
Author

author-{nicename}.php – If the author’s nickname is rami, WordPress will look for author-rami.php (supported by WordPress 3.0 and above)
author-{id}.php – If the author ID is 6, WordPress will look for author-6.php (supported by WordPress 3.0 and above)
author.php
archive.php
index.php
date page
date.php
archive.php
index.php
search results
search.php
index.php
404 (not found) page
404.php
index.php
attachment page
MIME_type.php – can be any MIME type (image.php, video.php, audio.php, application.php or other).
attachment.php
single.php
index.php