Since: 2.0
pods_view
Include a file that’s child/parent theme-aware, and can be cached into object cache or transients
For more information see the tutorial Partial Page Caching and Smart Template Parts with Pods.
Function Definition
function pods_view ( $view, $data = null, $expires = false, $cache_mode = 'cache', $return = false )
Source File: /pods/includes/classes.php
Parameters
Parameter | Type | Details |
---|---|---|
$view | (string) | Path of the file to be included, this is relative to the current theme |
$data | (array|null) | (optional) Data to pass on to the template, using variable => value format |
$expires | (int|bool) | (optional) Time in seconds for the cache to expire, if false caching is disabled. |
$cache_mode | (string) | (optional) Specify the caching method to use for the view, available options include cache, transient, or site-transient |
$return | (bool) | (optional) Whether to return the view or not, defaults to false and will echo it |
Returns
(string|bool) The view output
Examples
Example 1
Grab the sidebar and pass a variable to it, without having to set it global (messy)
<?php
$my_local = "I'm accessible in sidebar.php, unlike using get_template_part()";
pods_view( 'sidebar.php', compact( array_keys( get_defined_vars() ) );
Example 2
Echo the rss-feed.php file and cache it for future use as a transient for 3600 seconds (60 minutes)
<?php
pods_view( 'rss-feed.php', null, 3600, 'transient' );