Special Magic Tags

If you want to pull back dynamic information from the Logged-in User, or Parameter Values or other special information about your WordPress site, you want to use the Special Magic Tags

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

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, using get_template_directory_uri().
  • {@stylesheet-url}  returns the url for the currently active theme directory get_stylesheet_directory_uri().
  • {@site-url}  returns the url for the current site using site_url().
  • {@home-url}  returns the home url for the current site using home_url().
  • {@admin-url}  returns the url for the admin area of the current site using admin_url().
  • {@includes-url}  returns the URL for the includes area (wp-includes) for the current site using includes_url().
  • {@plugins-url}  returns the url for the plugin directory using plugins_url().
  • {@network-site-url}  returns the URL for the main site for a multisite network using network_site_url().
  • {@network-home-url}  returns the home URL for the main site for a multisite network using network_home_url().
  • {@network-admin-url}  returns the URL for the Network Admin area for the current site using network_admin_url().
  • {@user-admin-url}  returns the url for the admin area for the current user via user_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, for http://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, for http://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 to get_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 like user_login
  • {@date.Y-m-d} is equivalent to date_i18n('Y-m-d')
  • {@pods.any_field} is equivalent to $pods->field('any_field')
  • {@pods_display.any_field} is equivalent to $pods->display('any_field')
  • {@post_id} is equivalent to get_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.

Other Helpful Documentation on Magic Tags

Display Filters with Magic Tags

Used to modify the output of your fields using built-in or custom functions, especially helpful for conditional formatting or for complicated display rules.

Using Magic Tags

Explains the common usage for Magic Tags, where they can be used and how to access the standard post fields, custom fields and media fields in a Custom Post Type or Taxonomy.