Pods supports loading template files directly from the theme.
There are two kinds of templates in Pods:
- Pod Templates component that lets you create reusable templates across your site
- Plain templates that you provide through custom code within the corresponding Pods Block or Pods Shortcode context
Contents
Pod Templates Hierarchy
Pod Templates can be automatically loaded from the theme when the template code is left empty AND the template name must only contain allowed characters: alphanumeric, dashes, and forward slashes (/)
Code reference: $obj will be provided to your file and it will contain the current Pods object with all of the context available to it.
Example template: “book-list” (Template must be created first)
Template Hierarchy (in order of existence check)
pods/templates/book-list.php(new path added in Pods 3.2.8+)pods/book-list.phppods-book-list.phpbook-list.php- There is no generic catchall file
You can customize this list using the filter pods_template_default_templates and override the array of files provided (without the .php extension).
When providing custom code to use in the context of a Pods Block or Pods Shortcode (even with the Templates component active) — those templates are treated as Plain Templates. See the next section for how Plain Templates work.
Custom options
You can specify custom PHP header information to enable specific options. Right now there’s only one option available.
Enabling Magic Tags
<?php /** * Pod Template: Your template name * Magic Tags: Enabled */ ?> Your pod template goes here
Plain Templates (Templates component inactive)
When not using the Templates component in Pods, those templates are treated as Plain Templates and are restricted to only supporting magic tags and do not have a mechanism for file-based templates.
Diagram
Here’s a handy diagram that you can use to reference for Pod Template Hierarchy.
