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
Search
Popular on Blogar
Content Marketing-What is Content Marketing
- October 24th, 2023
- 1401 Views
Social Media Marketing-Social Media Marketing (SMM)
- October 24th, 2023
- 1692 Views
Pay-Per-Click-What is PPC
- October 24th, 2023
- 1271 Views
How to Activate Windows 11 Pro (No tools needed)
- September 3rd, 2024
- 99 Views
How to disable automatic updates for themes and plugins in WordPress
- August 16th, 2024
- 97 Views
Get all WordPress category names and IDs
- August 21st, 2024
- 95 Views
WordPress sticky articles in categories but not on the homepage
- August 13th, 2024
- 94 Views
WordPress-How to show single post content in front-end?
- August 26th, 2024
- 91 Views
WordPress display articles by category
- August 28th, 2024
- 86 Views
How To Find The IP Of Any Whatsapp Call
- September 3rd, 2024
- 85 Views
Recent Post
Content Marketing-What is Content Marketing
- October 24th, 2023
- 1401 Views
Social Media Marketing-Social Media Marketing (SMM)
- October 24th, 2023
- 1692 Views
Pay-Per-Click-What is PPC
- October 24th, 2023
- 1271 Views
VMware cannot install VMware Tools, prompts VMCI, memory driver
- November 25th, 2024
- 57 Views
More Post
- Howo Tractor Truck
- Howo Tipper/Dump Truck
- Howo Cargo Truck
- Howo Concrete Mixer Truck
- Howo Special Truck
- Howo Light Truck
- Shacman Tractor Truck
- Shacman Tipper/Dump Truck
- Shacman Cargo Truck
- Shacman Concrete Mixer Truck
- LGMG Mining Trucks
- XCMG Wheel Loader
- XCMG Excavator
- XCMG Crane
- XCMG Asphalt Pavers
- XCMG Road Roller
- Shantui Bulldozer
Copyright © 2024 BBBBF All Rights Reserved.