Dissecting WordPress Themes Part 11: Page Hierarchy

In this article we’ll explore the template hierarchy for pages. We’ll first create a few pages in our development instance and take a look at the default page display using the template of last resort, index.php. We’ll then begin to layer on templates from the hierarchy, demonstrating how each more specific template overrides its more general parent. We’ll examine the role of custom page templates in the hierarchy by creating one and assigning it to a few of our pages. Finally, we’ll observe how we can use page templates to design pages with both static and dynamic content.

Dissecting WordPress Themes Part 10: Post Type Hierarchy

In this part we wrap up our discussion of post archives with the custom post type archive hierarchy. WordPress allows you to achieve special formatting for a particular custom post type by using the archive-[post type].php template, where [post type] is the name given to our custom post type. This template overrides archive.php, which is a common template for all archive pages. We will also learn how to generate the link for a custom post type archive and exclude the archive page from the merging of normal posts and custom posts that we implemented on the other archive pages.

Dissecting WordPress Themes Part 9: Taxonomy Hierarchy

You are no doubt familiar with the built-in WordPress taxonomies: categories and tags. You can also create your own independent custom taxonomies, complete with an administration screen UI for managing terms and automatic archive searches. In this article we will continue our exploration of the archive hierarchies by examining the custom taxonomy archive. We’ll create a non-hierarchical custom taxonomy, add terms to it, and assign those terms to our existing posts. We’ll then implement the taxonomy templates to demonstrate how each more specific template overrides its more general parent in the template hierarchy. We’ll finish up with a brief look at the wp_tag_cloud() call to create a term cloud in our footer.php template.

Dissecting WordPress Themes Part 8: Date Hierarchy

WordPress provides the ability to filter posts based on particular publishing timeframes such as for a day, month, or year. For example, blog readers may click on a month link to see a list of posts published during that month. As with all archives, the date-based archives will use the archive.php template file if it is available in the theme, otherwise index.php will be used. Additionally, a theme developer may provide special formatting for date archive pages by overriding archive.php with date.php. Although there are not templates for individual date timeframes, conditional tags may be used to provide formatting specific to day, month, or year archives if needed. In this article, we’ll assign publication dates to our existing posts and use these to demonstrate the date archive hierarchy. We’ll also create simple month and year links in our sidebar.php and footer.php templates.

Dissecting WordPress Themes Part 7: Author Hierarchy

The author archive hierarchy allows readers to search for and filter posts based on author. It is usually requested by clicking a link on the author’s name to navigate to a page listing only the posts published by the selected author. The archive.php template common to all of the archives will be used to fulfill the request if it is present in the theme directory. However, the theme creator can override this template with author.php if special formatting is required for author archives. Additionally, author-specific formatting can be achieved by enlisting author-[id].php and author-[nicename].php. In this article we will create users, assign them to our existing posts, and then exercise this author hierarchy level-by-level. We’ll also add a list of author links to our footer template.

Dissecting WordPress Themes Part 6: Tag Hierarchy

We continue our exploration of the WordPress archive template hierarchy with a look at tags. The tag hierarchy is very similar to the category hierarchy with templates for all tags (tag.php) as well as specific tags (tag-[id].php and tag-[slug].php). We begin by adding tags to the database and then assigning them to our existing posts and custom post type. We then exercise the tag hierarchy level-by-level showing how more specific templates override more general templates. We then wrap up with a short demo of adding a tag cloud to our footer.php.

Dissecting WordPress Themes Part 5: Category Hierarchy

This article begins our tour of the archive template hierarchy with a look at the category archives. We begin by adding categories and assigning them to our existing posts. We then start at the root of the archive hierarchy with archive.php and continue with the category-specific template, category.php. We also take a look at the individual category templates based on category ID and slug. Along the way we’ll visit the parent/child relationship inherent in the category taxonomy and see how easy it is to add an independent list of categories to our sidebar.php template.

Dissecting WordPress Themes Part 4: Attachment Hierarchy

You can attach files of pretty much any type to your WordPress posts and pages. Once attached, files can be viewed or downloaded directly from a post or through attachment pages that can be formatted any way you want in your theme. In this article we continue our exploration of the WordPress Template Hierarchy for attachment pages. The attachment page hierarchy builds off of single.php to include levels for generic attachments and several media type patterns based on MIME type and subtype. We’ll visit each of these template files using files of various media types that we upload to the Media Library.

This article will teach you how to attach files. If you want to learn how to attach babies (MIME type human/infant), visit MilkyWayBreastfeeding.com.

Dissecting WordPress Themes Part 3: Single-Post Hierarchy

The WordPress Template Hierarchy allows selective, dynamic replacement of generic template files with more specific template files by just creating them in the theme directory. In this article we’ll begin our exploration of the template hierarchy for single posts, post formats, and custom post types. We will create a functions.php file, where we’ll utilize a few action hooks in order to implement post formats and a custom post type. We’ll also show how to integrate the custom post type into our main post stream.

Dissecting WordPress Themes Part 2: The Loop

We continue our series on understanding themes by learning about the famous WordPress Loop. The Loop is responsible for retrieving posts from the database and displaying them on a web page. In addition to coding a basic Loop, we’ll look at several more template tags, style sheet linking, a few important WordPress configuration settings, and page navigation.