[pods] shortcode
The pods shortcode allows you to place Pod item information, a Pods form, or even a theme template file directly into your content or via any shortcode-enabled content field. You may use magic tags, including special magic tags in Pods shortcodes.
Additional Parameter Options
Examples
List
List all items whose value for a specific field matches a string. The example assumes you're working with a Custom Post Type and my_field is a custom field within that post type.
[pods name="pod" limit="3" where="my_field.meta_value = 'Great'"]{@post_title} is great![/pods]
Single
Show a single item determined by post ID or post slug.
[pods name="pod" id="5"]{@my_field} is great![/pods]
[pods name="pod" slug="my-item"]{@my_field} is great![/pods]
Display a field from a single Pod item
[pods id="1" field="post_title"]
[pods slug="the-post-slug" field="post_title"]
[pods slug="the-post-slug"]{@post_title}[/pods]
[pods name="pod" id="5" field="my_field"]
[pods name="pod" slug="my-item" field="my_field"]
Display a field from the current post
[pods field="my_custom_field"]
[pods]{@my_custom_field}[/pods]
Form with all fields
Output a form with all fields in a Pod.
[pods name="pod" form="1"]
Form With Specific Fields
Output a form with only the specified fields.
[pods name="pod" form="1" fields="my_field,another_field"]
Include a file from a theme, with caching options
[pods view="includes/awesome-list.php" cache_mode="cache" expires="3600"]
Use a template to display fields.
By specifying a Pods Template in the "template" argument you can display one or more items with that template.
The first example displays a specific post item (id=5); the second example shows a list of 5 items.
[pods name="pod_name" template="template_name" id="5"]
[pods name="pod_name" template="template_name" limit="5"]
Show a Pods Page
You can display one or more items in a Pod, using Pods pages, via a shortcode.
[pods name="pod_name" page="page_name" id="5"]
[pods name="pod_name" page="page_name" limit="5"]
Related Actions/Filters
Additional Information
Calling Shortcodes within Pods Templates (or Manual Templates)
By default including a shortcode within a Pods shortcode (nesting it within the "pods" shortcode above or building a shortcode within a Pods Template or Custom Template with Magic Tags) will not work. If you need this functionality to work, you need to include the following constant in your wp_config.php file:define('PODS_SHORTCODE_ALLOW_SUB_SHORTCODES',true);
If you need to parse a shortcode within the Pods template, custom template or within your Pods shortcode, just add shortcodes=1
to the Pods shortcode.
If you don't want to have to remember to do that, you can include the following function within your functions.php for the theme or within your own plugin files if you've chosen to include your Pods code in it's own plugin:
<?php
/**
* Allow Pods Templates to use shortcodes
*
* NOTE: Will only work if the constant PODS_SHORTCODE_ALLOW_SUB_SHORTCODES is defined and set to
true, which by default it IS NOT.
*/
add_filter( 'pods_shortcode', function( $tags ) {
$tags[ 'shortcodes' ] = true;
return $tags;
});