Since: 2.3.10
pods_v
Return a variable, if one exists.
Function Definition
function pods_v( $var = null, $type = 'get', $default = null, $strict = false, $params = array() )
Source File: /pods/includes/data.php
Parameters
Parameter | Type | Details |
---|---|---|
$var | (mixed) | The variable name, can also be a modifier for specific types |
$type | (string|array|object) | (optional) Super globals, url/url-relative, constants, globals, options, transients, cache, user data, Pod field values, dates |
$default | (mixed) | (optional) The default value to set if variable doesn't exist |
$strict | (bool) | (optional) Only allow values (must not be empty) |
$params | (array) | (optional) Set 'casting'=>true to cast value from $default, 'allowed'=>$allowed to restrict a value to what's allowed |
Additional Parameter Options
Returns
(mixed) The variable (if exists), or default value
Examples
Use pods_v To Get Post Slug For Pods Page
pods_v() can be very useful for retrieving the permalink or slug of an Advanced Content Type and using it to set the Pods object for a single item. This examples presumes that the "Detail Page URL" field under the "Advanced Options" tab in the Pods Editor is set to "pod_name/{@permalink}/" or any other scheme where the permalink field is the final segment of the URL. Otherwise, you will need to specify the URL segment with an integer, starting from zero.
// get current item
$slug = pods_v( 'last', 'url' );
// get pods object for current item
$pods = pods( 'pod_name', $slug );