template-parts

The template-parts folder stores template components, organized in subfolders for clarity. You can create or edit folders as needed, adjusting the folder path in files when calling a template.

blocks

The blocks folder contains templates or scripts related to Gutenberg blocks. Gutenberg is WordPress’s block-based editor, and this folder will house custom blocks or styles that enhance or extend the editor’s functionality.

Usage: Custom Gutenberg blocks are typically registered through JavaScript and PHP, allowing users to add these custom elements directly from the Gutenberg editor when creating or editing posts and pages.

elements

The elements folder is dedicated to smaller, reusable UI components or functionality modules in your theme.

  • query-page.php: The template part for displaying the page query.
  • query-post.php: The template part for displaying the post query.
  • result-none.php: The template part for displaying an empty result element from the page query.
  • result-page.php: The template part for displaying the resulting element from the page query.
  • result-post.php: The template part for displaying the resulting element from the post query.

Usage: These elements can be included wherever needed using WordPress’s get_template_part() function, ensuring consistency in design and behavior.

layouts

The layouts folder houses primary structural components of your WordPress theme.

  • header.php: The template part for displaying the header layout.
  • footer.php: The template part for displaying the footer layout.

Usage: These layout components are typically included in primary template files using get_header(), get_footer() or a custom functions.

views

The views folder contains template fragments for rendering specific types of content within the WordPress theme. These templates dictate how different content types, like posts, pages, or custom types identified by slugs, are displayed on the site.

  • content-none.php: The template part for displaying an empty content view.
  • content-page.php: The template part for displaying the content page view.
  • content-post.php: The template part for displaying the content post view.
  • content-search.php: The template part for displaying content search view.

Usage: These view templates are typically incorporated into primary theme files (like single.php, page.php, or search page) using WordPress’s get_template_part() function. This allows the main template files to remain clean and concise, offloading content-specific styling and structuring to the views folder.

widgets

The widgets folder contains files related to WordPress widgets—small blocks that perform specific functions, like displaying recent posts, search bars, or custom content.

Usage: Widgets are typically used in widget-ready areas defined by the theme, such as sidebars or footers. Developers create custom widgets by extending the WidgetAreas class and then register them for users to drag and drop in the WordPress admin dashboard.


First PublishedAugust 17, 2023
Last UpdatedAugust 17, 2023