![]() ![]() This is an interactive version of the Codex’s template hierarchy image. Interactive Template Hierarchy Resource, at.Learn to love it! On this page, you can learn what each type of template file does. The Codex is the canonical source for information on the template hierarchy, and on WordPress itself. Template Hierarchy on the WordPress Codex, at.The diagram above is great, but there are a few other great ways to visualize and understand the template hierarchy: When this bundle hits the template hierarchy-starting from the left of the diagram-the hierarchy recognizes your “Page Type” as “Blog Posts Index Page.”Īre you starting to get how the template hierarchy works? Once you understand the basic concept, making WordPress themes that benefit from this knowledge simply requires creating and modifying the proper template files for the types of webpages you wish to affect. Whatever webpage your blog index is, WordPress knows when you’re visiting it, and it’ll fetch a bundle of your most recent Posts. Choosing a “static page” for your blog index page will change the blog index’s URL to something like /blog, for a Page titled “Blog,” or /news, for a Page titled “News.” However, you can also set your blog index to appear at the URL of an existing “static page” (meaning a Page). If you leave the setting as its default, then your blog index is your site’s homepage: the webpage you see when you navigate to. But which page is this, specifically? It depends on your site’s settings in Settings > Reading: ![]() This is the page on your website that displays your most recent Posts. Let’s take a second trip through the template hierarchy, this time with the site’s blog index page. This chapter explains how the template hierarchy makes its decisions. The template hierarchy is a built-in system in WordPress that specifies which line to send a given bundle of posts down, based on properties of the bundle itself. How do we know which assembly line a given bundle will go down? With the WordPress template hierarchy. Putting our posts through index.php will result in a webpage that looks one way putting it through home.php, archive.php, or page.php will give very different results. However, the theme provides a lot of possible lines to send those posts down: our different PHP templates. In this chapter, we’re in the stage of the production process where a bundle of posts has been fetched out of the warehouse (the database), and are all ready to be assembled and made to display beautifully by our assembly line, the WordPress theme. Learning this hierarchy will let you pinpoint which of your webpages will use which template.Īs we work through this chapter, remember the following analogy: WordPress is a factory that processes raw material, posts, into finished products, webpages. The template hierarchy follows a defined order set in WordPress itself.The WordPress template hierarchy determines which PHP template files will be used to construct a given webpage on your site, based on the type of post content requested: for example, whether the webpage displays a Page, a Post, or an archive of many Posts.
0 Comments
Leave a Reply. |