WordPress Taxonomy

WordPress Taxonomy

Commonly used WordPress theme files

Standard 404.php Error page, served up when someone goes to a URL on your site that doesn’t exist
Standard archive.php Page that displays posts in one particular day, month, year, category, tag, or author
Optional archives.php Page template that includes search form, category list, and monthly archives (requires page using it)
Standard comments.php This file delivers all the comments, pingbacks, trackbacks, and the comment form when called
Standard footer.php Included at the bottom of every page. Closes off all sections. (Copyright, analytics, etc)
Optional functions.php File to include special behavior for your theme.
Standard header.php Included at the top of every page. (DOCTYPE, head section, navigation, etc)
Optional image.php If you wish to have unique pages for each of the images on your site (for credits, copyright…)
Standard images DIRECTORY – Keeps all the images that make up your theme in one place
Core index.php This is typically the “homepage” of your site, but also the default should any other views be missing
Optional links.php Special page template for a home for your blogroll
Standard page.php Template for Pages, the WordPress version of static-style/non-blog content
Optional rtl.css A special CSS file for your optional inclusion to accommodate “right to left” languages
Standard screenshot.png This is the image thumbnail (880px x 660px) of your theme
Standard search.php The search results page template
Standard sidebar.php Included on pages where/when/if you want a sidebar
Standard single.php This file is displays a single Post in full (the Posts permalink), typically with comments
Core style.css The styling information for your theme, required for your theme to work, even if you don’t use it

What template will WordPress choose?

Page Tries First >> Tries Second …. >> Tries Last
404 404.php >> index.php
Search search.php >> index.php
Taxonomy taxonomy-{tax}-{term}.php  >> taxonomy-{tax}.php  >> taxonomy.php  >>  archive.php  >> index.php
Home home.php >> index.php
Attachment {mime-type}.php  >>  single.php  >> index.php
Single single-{post-type}.php  >> single.php >> index.php
Category category-{slug}.php >> category-{id}.php >> category.php >> archive.php >> index.php
Tag tag-{slug}.php >> tag-{id}.php >> tag.php  >> archive.php  >> index.php
Author author-{arthor-nicename}.php  >> author-{author-id}.php  >>  author.php >>  archive.php >> index.php
Date date.php >> archive.php >> index.php
Archive archive.php >> index.php

“How does WordPress figure out which template file to use?” You might assume that it is hard-wired into WordPress, but, most of the files in a theme are optional. If your theme doesn’t have an archive.php file, does WordPress just display a blank page? Absolutely not, it moves down its hierarchy of template files to find the next most appropriate file to use. Ultimately, all paths in the WordPress templating world end at the index.php file.

Just as we move down the hierarchy toward index.php, we can travel in the other direction and create template files that are very specific. For example, if we wish to have a unique template when viewing category #45 of our blog, we can create a file called category-45.php, and WordPress will automatically use it.

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.



Updated on October 29, 2021

Pixelated Dwarf