When it comes to field() notation, there are many useful options built into Pods.
Contents
Relationship / File Field Traversal
You can traverse into any relationship or file field to get at information directly.
Built-in taxonomy connections for a Post Type are also supported with this notation.
In the examples below, the “related_post” and “related_taxonomy” are field names for a relationship field. “my_file_field” is a field name for a file field. “*” works on any relationship/file field name.
| Notation | Description |
related_post.ID | Get the ID of the related post. |
related_post.post_title | Get the post title of the related post. |
related_taxonomy.term_id | Get the term ID of the related taxonomy. |
related_taxonomy.name | Get the term name of the related taxonomy. |
my_built_in_taxonomy.name | Get the term name of the built-in taxonomy “my_built_in_taxonomy”, only supported for Post Types. |
my_file_field.ID | Get the ID of the uploaded file for the file field. |
*.another_relationship | Get the related data from the field “another_relationship” on the relationship field. |
*.another_relationship.ID | You can traverse as many levels as you would like into the related field. |
*.custom_simple_relationship | Get the related data from a simple relationship field on the related field. |
*.custom_meta_field | Get the value of a custom field on the related field. |
*.custom_table_field | Get the value of a custom table field (table-based Pods) on the related field. |
Post Thumbnails (when enabled on Post Types)
If you have Post Thumbnails (Featured Images) enabled for a Post Type, you can utilize this notation to get specific sizes as
<img /> tags or just get the image URL.
| Notation | Description |
post_thumbnail | Get the featured image as an <img /> tag
(size: “thumbnail”).
|
post_thumbnail.sizename |
Get the featured image as an
<img /> tag for a specific image size. The sizes accepted are: thumbnail,
medium, large, full,
any other registered image size, and custom pixel-based sizes like
400x100 (400 width, 100 height).
|
post_thumbnail_url | Get the featured image URL (size: “thumbnail”). |
post_thumbnail_url.sizename |
Get the featured image URL for a specific image size. The sizes accepted are: thumbnail,
medium, large, full,
any other registered image size, and custom pixel-based sizes like
400x100 (400 width, 100 height).
|
User Avatars
This is only supported when used on a User pod.
| Notation | Description |
avatar |
Get the avatar image
as an <img /> tag (size: “96”).
|
avatar._url | Get the avatar image URL (size: “96”). |
avatar.32 |
Get the
avatar image
as an
<img /> tag for a specific pixel-based size. The pixel size must be less than 512.
|
avatar._url.32 | Get the avatar image URL for a specific pixel-based size. The pixel size must be less than 512. |
File Field Image / URL and Sizing
In the examples below, “my_file_field” is the field name for a file field.
| Notation | Description |
my_file_field._img |
Get the file image as an <img /> tag
(size: “full”).
|
my_file_field._img.sizename |
Get the file image as an <img /> tag
for a specific image size.
The sizes accepted are: thumbnail, medium, large,
full, any other registered image size, and custom pixel-based sizes like
400x100 (400 width, 100 height).
|
my_file_field._src | Get the file URL (size: “full” if it is an image). |
my_file_field._src.sizename |
Get the file image URL.
The sizes accepted are: thumbnail, medium, large,
full, any other registered image size, and custom pixel-based sizes like
400x100 (400 width, 100 height).
|
my_file_field._src_relative.sizename | Get the file image URL (relative to root domain) for a specific image size.
The sizes accepted are: thumbnail, medium, large,
full, any other registered image size, and custom pixel-based sizes like
400x100 (400 width, 100 height).
|
my_file_field._src_schemeless.sizename | Get the file image URL (schemeless, “//” instead of “https://”) for a specific image size.
The sizes accepted are: thumbnail, medium, large,
full, any other registered image size, and custom pixel-based sizes like
400x100 (400 width, 100 height).
|
Referenced Image Attachments
You can reference a specific attachment by ID and output information about it.
In the examples below, “123” is the attachment ID being referenced.
| Notation | Description |
image_attachment.123 |
Get the attachment image as an <img /> tag
(size: “thumbnail”).
|
image_attachment.123.sizename |
Get the attachment image as an <img /> tag
for a specific image size.
The sizes accepted are: thumbnail, medium, large,
full, any other registered image size, and custom pixel-based sizes like
400x100 (400 width, 100 height).
|
image_attachment_url.123 | Get the attachment image URL (size: “thumbnail”). |
image_attachment_url.123.full |
Get the attachment image URL for a specific image size.
The sizes accepted are: thumbnail, medium, large,
full, any other registered image size, and custom pixel-based sizes like
400x100 (400 width, 100 height).
|
Pod Information
Since: 2.8
You can reference various information about the current pod.
| Notation | Description |
_pod | Get the current pod name. |
_pod.label | Get the current pod label. |
_pod.type | Get the current pod type (post_type, taxonomy, user, media, comment, pod). |
_pod.id | Get the current pod ID. |
_pod.some_option | Get the value for any option on the current pod. |
Field Information
Since: 2.8
You can reference various information about a specific field on the current pod.
| Notation | Description |
_field.my_field_name | Get the field label for a specific field on the current pod. |
_field.my_field_name.label | Get the field label for a specific field on the current pod. |
_field.my_field_name.type | Get the field type for a specific field on the current pod. |
_field.my_field_name.id | Get the field ID for a specific field on the current pod. |
_field.my_field_name.some_option | Get the value for any option for a specific field on the current pod. |
Item List Information
Since: 2.8
When you are in a fetch() loop or in a template that is used in an item list, you can reference various information about the current loop context.
| Notation | Description |
_zebra | Get the “1” or “0” value, depending on if the current item position is odd. |
_position | Get the position of the current item in the list (starting with 1). |
_total | Get the total number of items on the page. |
_total_found | Get the total number of matching items in the database, regardless of limit set. |
_total_pages | Get the total number of pages available. |
_current_page | Get the current page number. (Since: 2.8.23) |
Context Information
Since: 2.8
You can get helpful information based on various contexts on any page directly from field(). It is most helpful when paired with the [if] conditional template tag. This functionality relies on the contexts supported by pods_v(). All values will be sanitized before returned including removal of HTML tags.
| Notation | Description |
_context.get.some-value | Get the value of $_GET['some-value']. |
_context.post.some-value |
Get the value of $_POST['some-value'].
|
_context.* | Get the value of a specific context. The supported contexts are: template-url,
stylesheet-url, site-url, home-url, admin-url,
includes-url, content-url, plugins-url,
network-site-url, network-home-url, network-admin-url,
user-admin-url, prefix, post_id |
_context.*.some-value | Get the value of a specific context option. The supported contexts are: get,
post, request, query, url, uri,
url-relative, session, cookie, user,
option, site-option, date, pods,
pods_display |
Auto Display Fields
Since: 2.9.4
You can now automatically display field labels and field values without writing the markup yourself. This notation can get a little hard to read so you may want to use the corresponding Pods Single Item – List Fields block.
| Notation | Description |
_all_fields | Display all field labels and field values for a Pod in a <ul> list. |
_all_fields.ul | Display all field labels and field values for a Pod and specify the format to use. Available display formats include ul, ol, dl, p, div, and table. The default is ul. |
_display_fields.ul.field_name | Display the field labels and field values for specific fields in Pod using the specified format. Available display formats include ul, ol, dl, p, div, and table. Separate field names using a “|” pipe character like: field_name|another_field|etc |
_display_fields.ul.related_post:post_title
| Display the field label and field value for a relationship field where you want to output just the post_title field. Traversal is supported for any relationship/file field. Instead of using “.” dot traversal, you will want to traverse with the “:” colon character. Available display formats include ul, ol, dl, p, div, and table. |