• Tweet

A WordPress theme is made up of a number of different files, and they all contain a seperate section of the page; the header will contain the title and navigation, then the index will contain the main content area . The sidebar obviously contains the sidebar and the footer contains the footer and closes off the HTML. This all sounds very straightforward, but the important bit is how you can just have a single file, change it once and you will change your whole site. Change your footer and that change will be reflected sitewise, not just on a single page.

Commonly Used WordPress Theme Files

Of course, the look of all themes is different. we’ll be looking at all the different the files that exist in WordPress.

CORE (required)

index.php This is typically the “homepage” of your blog, but also the default should any other views be missing

style.css The styling information for your theme, required for your theme to work, even if you don’t use it

STANDARD (used in most themes)

404.php Error page, served up when someone goes to a URL on your site that doesn’t exist

archive.php Page that displays posts in one particular day, month, year, category, tag, or author

comments.php This fle delivers all the comments, pingbacks, trackbacks, and the comment form when called

footer.php Included at the bottom of every page. Closes off all sections. (Copyright, analytics, etc)

header.php Included at the top of every page. (DOCTYPE, head section, navigation, etc)

images FOLDER – Keeps all the images that make up your theme in one place

page.php Template for Pages, the WordPress version of static-style/non-blog content

screenshot.png This is the image thumbnail of your theme, for help distinguishing it in the Appearance picker

search.php The search results page template

sidebar.php Included on pages where/when/if you want a sidebar

single.php This fle is displays a single Post in full (the Posts permalink), typically with comments

SPECIAL(optional additions)

archives.php Page template that includes search form, category list, and monthly archives (requires page using it)

functions.php File to include special behavior for your theme.

image.php If you wish to have unique pages for each of the images on your site (for credits, copyright…)

links.php Special page template for a home for your blogroll

loop.php Common in newer themes, an optional fle to house your custom, multiple, or regular loops

rtl.css A special CSS fle for your optional inclusion to accommodate “right to left” languages

Understanding How Theme Files Work Together

In wordpress theme index.php and style.css are essential for your theme. WordPress will not recognize any theme if these two files are not in the theme folder. You can build a simple theme using two files. But to make your site more efficient we use standard and special files.

WordPress themes files are interact with each other. They call upon each other to get the job done. This dynamic approach gives wordpress theme building a lot of power. For example, index.php alone will call and insert header.php at the top of it, sidebar.php in the middle of it, and footer.php at the bottom of it. Then, the header.php file will includes the section, will call upon the style.css file. So header, sidebar, content area and footer of the theme, as shown below:

Understanding Diferent Page Views

There are really only a handful of different types of page views:

• The Home Page – usually at the root URL of your domain

• Single Posts – displays one post at a time, usually in its entirety

• Static Pages – pages that are outside the fow of normal posts

• Custom Pages – static pages that have been customized

• Search Results – displays a list or summary of posts matching a search

• Archive – shows series of posts for categories, tags, dates, and authors

How WordPress Decides Which File to Use for Rendering the View

It is important that which template file will use in different page views. Here we see that most of the theme files are optional. Suppose archive.php file is missing, does WordPress just display a blank page? Absolutely not, it moves down its hierarchy of template file and use the most appropriate file. Just look at the flowchart, hope you will get a clear idea.