field() Notation Options

Available field() notation options.

When it comes to field() notation, there are many useful options built into Pods.

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.

NotationDescription
related_post.IDGet the ID of the related post.
related_post.post_titleGet the post title of the related post.
related_taxonomy.term_id Get the term ID of the related taxonomy.
related_taxonomy.nameGet the term name of the related taxonomy.
my_built_in_taxonomy.nameGet the term name of the built-in taxonomy “my_built_in_taxonomy”, only supported for Post Types.
my_file_field.IDGet the ID of the uploaded file for the file field.
*.another_relationshipGet the related data from the field “another_relationship” on the relationship field.
*.another_relationship.IDYou can traverse as many levels as you would like into the related field.
*.custom_simple_relationshipGet the related data from a simple relationship field on the related field.
*.custom_meta_fieldGet the value of a custom field on the related field.
*.custom_table_fieldGet 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.

NotationDescription
post_thumbnailGet 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.

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

NotationDescription
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.sizenameGet 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.sizenameGet 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.

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

NotationDescription
_podGet the current pod name.
_pod.labelGet the current pod label.
_pod.typeGet the current pod type (post_type, taxonomy, user, media, comment, pod).
_pod.idGet the current pod ID.
_pod.some_optionGet 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.

NotationDescription
_field.my_field_nameGet the field label for a specific field on the current pod.
_field.my_field_name.labelGet the field label for a specific field on the current pod.
_field.my_field_name.typeGet the field type for a specific field on the current pod.
_field.my_field_name.idGet 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.

NotationDescription
_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_foundGet the total number of matching items in the database, regardless of limit set.
_total_pagesGet the total number of pages available.
_current_pageGet 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.

NotationDescription
_context.get.some-valueGet 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-valueGet 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.

NotationDescription
_all_fieldsDisplay all field labels and field values for a Pod in a <ul> list.
_all_fields.ulDisplay 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_nameDisplay 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.

Other Helplful Documentation on pods() or go back to field()

add_to()

Add an item to the values of a relationship field.

add()

Add an item to a Pod.

data()

Return an array of all rows returned from a find() call.

delete()

Delete an item from the Pod.

display()

Return the output for a field.

do_magic_tags()

Replace magic tags with their values.

duplicate()

Duplicate an item.

exists()

Whether a Pod item exists or not when using fetch() or construct with an ID or slug.

export_data()

Export data from all items.

export()

Export an item’s data.

fetch()

Fetch an item from a Pod.

field()

Return the value for a field.

fields()

Return field array from a Pod, a field’s data, or a field option.

filters()

Output search filters to be used with find().

find()

Find items of a pod.

first_id()

Return the first item ID.

form()

Embed a form to add / edit a pod item from within your theme.

helper()

Run a helper within a Pod Page or WP Template.

id()

Return the item ID.

import()

Import data.

index()

Return the item name.

last_id()

Return the last item ID.

next_id()

Return the next item ID.

nth()

Fetch the nth state.

pagination()

Display the pagination controls.

position()

Fetch the current position in the loop.

prev_id()

Return the previous item ID.

raw()

Return the raw output for a field.

remove_from()

Remove values from fields.

reset_pod()

Delete all items from the Pod.

reset()

Reset the item position back to the start of the find() list.

row()

Return row array for an item.

save()

Save an item.

template()

Display the page template.

total_found()

Fetch to total number of rows found.

total()

Fetch the total row count.

valid()

Pod object validity.

zebra()

Fetch the zebra switch.