Skip to toolbar

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.

Before Pods 2.3.10 in order to use some special magic tags you had append a period to the magic tag. For example, {@template-url} would need to be {@template-url.} to return the value of get_template_directory_uri().

Important: In many cases, such as inside a shortcode, or in the Pods widget settings, you must add the following define('PODS_SHORTCODE_ALLOW_EVALUATE_TAGS',true); to your wp_config.php 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/ {@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/ {@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’ ]
  • {@server.any} is equivalent to $_SERVER[ ‘any’ ]
  • {@session.any} is equivalent to $_SESSION[ ‘any’]
  • {@cookie.any} is equivalent to $_COOKIE[ ‘any’ ]
  • {@constant.ANY} is equivalent to the constant ANY
  • {@globals.any} is equivalent to $GLOBALS[ ‘any’ ]
  • {@user.any} is equivalent to getting the ‘any’ field from the currently logged in user, whether it’s a meta field or a core field like user_login
  • {@option.any} is equivalent to get_option( ‘any’ )
  • {@site-option.any} is equivalent to get_site_option( ‘any’ )
  • {@transient.any}is equivalent to get_transient( ‘any’ )
  • {@site-transient.any}is equivalent to get_site_transient( ‘any’ )
  • {@cache.any}is equivalent to wp_cache_get( ‘any’ )
  • {@date.Y-m-d}is equivalent to date_i18n( ‘Y-m-d’ )
  • {@pods.any}is equivalent to $pods->field( ‘any’ )
  • {@pods_display.any}is equivalent to $pods->display( ‘any’ )

Usage and Caveats

We need to put more examples here, but the first thing to note is the usage locations for these Special Magic Tags. They can only be used in WHERE clauses and the special Customized clauses in relationship fields. These fields can not just be dropped in a Pods Template and expect them to work.

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:

Howdy {@user.display_name}! and expect it to work. It won’t because that’s a special magic tag. You would need to extend Users (see Extending Users) and call a shortcode like this:

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}.