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.

Overview

Magic tags can be used in Pods Templates, Shortcode Custom Templates, and Pods Page Titles to easily return field values. These magic tags take the form of {@field_name}. Pods automatically retrieves the value of the field name specified in the magic tag. For example, {@lightsaber_color} returns the value for the field “lightsaber_color.”

In certain fields in the Pods editor and Pods shortcodes special magic tags can be used.

Examples of Common Usage

Custom Fields In A Pods Template With HTML Markup

This example returns values from “jedi_name” and “lightsaber_color” fields with HTML markup in a Pods Template.

<ul>
    <li><strong>Name:</strong> {@jedi_name}</li>
    <li><strong>Lightsaber Color:</strong> {@lightsaber_color}</li>
</ul>

List Using A Magic Tag In A Shortcode

This shortcode can be used in a post and will return a list of 9 names of Jedi who have attained the rank of master by searching the “jedi” Pod, for entries where the field “rank” equals “master” and returning the value for the field “name.”

[pods name="jedi" limit="9" where="rank.meta_value = 'master'"]{@name}[/pods]

Field From Current Post Using A Magic Tag In A Shortcode

A shortcode that can be used in a post to show the value for the field “lightsaber_color” from the current post.

[pods]{@lightsaber_color}[/pods]

Standard Usage for Different Kinds of Fields

Using Built-In WordPress Fields

All fields supported by the post type can be accessed in a magic tag. For example:

  • {@post_title}  The post title. {@title} also works.
  • {@permalink} The permalink to the post.
  • {@author} The post author ID.
  • {@post_date} The post date.
  • For all Post Specific fields, you can reference the field reference for Post Fields

Post thumbnails (where enabled)

  • {@post_thumbnail} The post thumbnail, thumbnail size.
  • {@post_thumbnail.full} The post thumbnail, resized. The last part specifies the size. Default is thumbnail, accepts thumbnail, medium, large, full, 400×111, etc).
  • {@post_thumbnail_url} The URL for the post thumbnail, thumbnail size.
  • {@post_thumbnail_url.full} The URL for the post thumbnail, resized. The last part specifies the size. Default is thumbnail, accepts thumbnail, medium, large, full, 400×111, etc).

Relationship Fields

It’s often better to use the [each relationship_field][/each]  blocks for looping through multiple records. The method below works best with single select relationships.

  • {@related_post_type.post_title} The title of the related post.
  • {@related_post_type.another_relationship} The value from a relationship field from a related post. This will usually return the value as an array list, like apples, oranges and bananas.
  • {@related_post_type.custom_simple_relationship} The value of a custom simple relationship, related to the related post.
  • {@related_post_type.custom_meta_field} The value of a custom meta field for the related post.

Taxonomies

Just like with relationships, if you’re expecting multiple terms to return from your taxonomy, you’re better off using the [each taxonomy_name][/each]  looping blocks to return all the connections below.

  • {@taxonomy_name.nameThe name of a term for a taxonomy associated with the post.
  • {@taxonomy_name.permalink} The permalink to the taxonomy term associated with the post.
  • {@taxonomy_name.slug} The name of the ‘slug’ for a taxonomy term associated with the post.
  • {@taxonomy_name.term_id} The term ID for a taxonomy term associated with the post.
  • {@taxonomy_name.custom_field} The value of a custom field for the taxonomy term associated with the post.

NOTE: You can only display the Taxonomy content if you have Extended it with Pods. This especially applies to the built-in category  or post_tag ; they will not show up in your magic tags if you have not extended the taxonomies.

Users

  • {@avatar The user avatar image.
  • {@avatar.32} The user avatar image, the number is the size to use in pixels. Default is 96, max is 512.

Files

  • {@file_field_name._src / file_field_name._src.full} For the URL of the full image size.
  • {@file_field_name._src.thumbnail} For the URL of the thumbnail image size.
  • {@file_field_name._src.sizename} For the URL of a custom image size.
  • {@file_field_name._src_relative.sizename} For the relative URL (to root domain) for custom image size (_src.* notation the same),
  • {@file_field_name._src_schemeless.sizename} For Schemeless URL (// instead of http://) for custom image size (_src.* notation the same).
  • {@file_field_name._img.sizename} For the image HTML for custom image size (_src.* notation the same).

Image Attachments

Provides special handling for the sizes, etc.

  • {@image_attachment.123} To output an image by attachment ID.
  • {@image_attachment.123.full} To output an image by attachment ID, the last part is the size to use, thumbnail default, accepts thumbnail, medium, large, full, 400×111, etc.
  • {@image_attachment_url.123} To output an image URL by attachment ID.
  • {@image_attachment_url.123.full} To output an image URL by attachment ID, the last part is the size to use, thumbnail default, accepts thumbnail, medium, large, full, 400×111, etc.
  • {@file_field_name._src / file_field_name._src.full} The URL for full image size.
  • {@file_field_name._src.sizename} The URL for custom image size.
  • {@file_field_name._src.thumbnail} The URL for thumbnail image size.
  • {@file_field_name._img / file_field_name._img.full} The HTML for full image size.
  • {@file_field_name._img.sizename} The HTML for custom image size.
  • {@file_field_name._img.thumbnail} The HTML for thumbnail image size.

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.

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