Although a theme only needs a index.php template, typically themes include numerous templates to display different content types and contexts. The most critical template file is index.php, which is the catch-all template if a more-specific template can not be found in the template hierarchy. If it doesn’t exist, it will fallback to the single.php template for displaying generic posts.Ī theme isn’t required to have these templates, but the more templates it has, the more granular control the theme has over how the different content is displayed: When a user visits a page on the site for a specific car, WordPress will look in the theme for a template file called single-car.php. For example, a car listing site has registered a custom post type of ‘car’. Specific template files are looked for in the theme, and fallbacks are used if they don’t exist. Template files are loaded in a specific manner, governed by the WordPress template hierarchy. Template files are “PHP files that contain a mixture of HTML, Template Tags, and PHP code.” The WordPress templating system is one of the most important pillars of the WordPress architecture. However, there are plugins that use template files to display content, and that becomes another consideration when it comes to building WordPress themes.Ĭan you override plugin template files? If so, how? If you are building a plugin that renders HTML, how can you make it easily altered by themes? In this article I’ll answer these questions. When we talk about templates in WordPress we are normally referring to page template files in the theme.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |