-
Notifications
You must be signed in to change notification settings - Fork 0
Template Hierarchy
Page templates should contain all of the logic for displaying the content.
A page template can come in two forms.
- One that contains
Template Name:
in the file's docblock and is selectable in the admin. - One that is used by WordPress core and not selectable in the admin, such as
archive-profile.php
.
A section is a repeatable part of a page that contains logic and most likely uses template parts to display content.
A great example of a section is a Related Posts. This could appear on multiple
pages in multiple contexts, but it will mostly be the same. It will contain the
logic (querying related posts and looping through them), but it will call
get_template_part( get_post_type(), 'related' )
or
r_get_template_part( get_post_type(), 'related' )
to display the actual
content.
Template parts are small, repeatable chunks of code that represent individual pieces of content. This should contain little to no logic. It is strictly for displaying a single piece of content.
Rule: Template parts representing post types should use the post type name.
Example: the degree_program
post type template parts should be named starting
with degree_program
.
There are a few exceptions to this organization.
If the template is single-custom_type.php
, for example, it is OK to not use a
template part here as long as the same markup and post content is not repeated
somewhere else.
Get started
Configuration
Build child themes
- Customizing CSS in a child theme
- Overriding templates in a child theme
- Code patterns
- Code reviews
- Pulling in Foundation Updates
- Merging and Creating a Pull Request
Sass
Javascript
PHP
- Coding Standards
- PHP Constants
- Temp PHP Code Patterns
- PHP Snippets
- How to Use Hooks
- Action Hooks
- Using Action Hooks To Output Markup
- Filter Hooks
Shortcodes
Templates
GitHub
Tasks
Contribute to the framework
- Framework Development and Release Workflows
- Documentation Template
- Testing your changes
- Creating a new release
- Migration Guide
- Needs Documentation
Code Examples
- Adding Content Container Classes
- Adding News Templates
- Adding Script Dependencies
- Changing Available Layouts and Default Layout
- Displaying a Fancy Gallery
- Loading a Custom Build of Modernizr
- Loading Modernizr in the Footer
- Using Action Hooks To Output Markup
- Understanding get_template_part
BU Developer Resources