Contents
Overview
In some limited cases, listed below, additional “special magic tags” are available for use in addition to regular field-based magic tags. Special magic tags are used for getting specific URLs in a WordPress site. They either use WordPress functions, such as get_template_directory_uri()
or plugins_url()
, or PHP actions.
Important: In many cases, such as inside a shortcode, or in the Pods Blocks / Widgets settings, you must set the PODS_SHORTCODE_ALLOW_EVALUATE_TAGS
constant for these tags to be used.
Situations Where Special Magic Tags Can Be Used
- In the relationship ‘where’/ ‘having’ options in the field editor
- In the menu icon option for the Pod. See this tutorial for additional info.
- In the ‘where’/ ‘having’ field of Pods shortcodes
- In the ‘Wildcard URL’ option of a Pod Page
List Of Special Magic Tags
Site Tags
{@template-url}
returns the url for the currently active theme directory or parent theme when using a child theme, usingget_template_directory_uri()
.{@stylesheet-url}
returns the url for the currently active theme directoryget_stylesheet_directory_uri()
.{@site-url}
returns the url for the current site usingsite_url()
.{@home-url}
returns the home url for the current site usinghome_url()
.{@admin-url}
returns the url for the admin area of the current site usingadmin_url()
.{@includes-url}
returns the URL for the includes area (wp-includes) for the current site usingincludes_url()
.{@plugins-url}
returns the url for the plugin directory usingplugins_url()
.{@network-site-url}
returns the URL for the main site for a multisite network usingnetwork_site_url()
.{@network-home-url}
returns the home URL for the main site for a multisite network usingnetwork_home_url()
.{@network-admin-url}
returns the URL for the Network Admin area for the current site usingnetwork_admin_url()
.{@user-admin-url}
returns the url for the admin area for the current user viauser_admin_url()
.
Dynamic Tags
For these types {@get.any}
is equivalent to pods_v( $var = 'any', $type = 'get' );
which for that $type is equivalent to $_GET['any']
. For example, {@post.any}
will get the value of $_POST['any']
if it’s been set.
{@get.any}
is equivalent to$_GET['any']
{@url.2}
pulls the level of the url for the number following the period. For example, forhttp://mysite.com/this/that/any/there/
the{@url.2}
pulls “any” level of the domain. Paths start at 0 and increase by one for each path level.{@url-relative.2}
pulls the level of the url for the number following the period, based off of the root of the WordPress URL. For example, forhttp://mysite.com/wordpress/this/that/any/there/
the{@url.1}
pulls “that” level of the domain. Paths start at 0 and increase by one for each path level.{@query.any}
is equivalent toget_query_var('any')
{@post.any}
is equivalent to$_POST['any']
{@request.any}
is equivalent to$_REQUEST['any']
{@user.any_field}
is equivalent to getting the ‘any_field’ field from the currently logged in user, whether it’s a meta field or a core object field likeuser_login
{@date.Y-m-d}
is equivalent todate_i18n('Y-m-d')
{@pods.
is equivalent toany_field
}$pods->field('
any_field
'){@pods_display.
is equivalent toany_field
}$pods->display('any_field')
{@post_id}
is equivalent toget_the_ID()
Usage and Caveats
As noted in the beginning of this doc page, there are specific places where Special Magic Tags can be used.
❌ These fields can not be used within Pods Templates.
As an example, if you’re wanting to show the current user who is logged in and information about them, you might think you could just create a template with the following: Hello, {@user.display_name}!
and expect it to work. It won’t because that’s a special magic tag and those aren’t supported in Templates themselves. You would need to extend Users (see Extending Users) and call a shortcode like this:
[pods name="user" where="t.ID = {@user.ID}"] Hello, {@display_name}! [/pods]
The shortcode is called against the extended user object and the where clause calls the correct record because it’s matching it against the currently logged-in user with the Special Magic Tag {@user.ID}
in the shortcode itself.