The “item” attribute is used to get the context when retrieving data from a post that is different from the current one. “Item” attribute described on this page is used by some Types shortcodes and some Views shortcodes related with post content.
If your site is using Types 3.0 or a newer version but you did not migrate its relationships to the many-to-many schema, the item attribute will accept the same values as those of the legacy id attribute. It will also output the same results. This ensures backward compatibility. In the event the site has already migrated its relationships, some changes will be applied to the attributes.
The item attribute can take the following values:
-
- numeric ID points to the ID of the post from which you want to retrieve data. If the numeric ID does not match an existing post, the data from the current post will be returned.
- $parent is used to retrieve data from a hierarchical parent if the current post is a type of hierarchical post such as a page. If the reference does not match an existing post, the data from the current post will be returned.
- $current_page is used to retrieve data from the current page being rendered. It can be used inside a View loop to obtain data from the page on which the View is being rendered.
- @{relationship-slug}.{relationship-role} is usedto retrieve data from a related post. This attribute and the values it can take depend on the context of the current post.
-
-
- If your current post is in a relationship acting as child post, you can use the value of @{relationship-slug}.parent to obtain data from the related parent. Note that this only makes sense when a unique parent exists. Therefore, the relationship should be one-to-one or one-to-many.
- If your current post is in a relationship acting as an intermediary post, you can use the value of @{relationship-slug}.parent to obtain data from the related parent. Note that this only makes sense when an intermediary post exists, which occurs only in many-to-many relationships.
- If your current post is in a relationship acting as a parent post, you can use the value of @{relationship-slug}.child to obtain data from the related child. Note that this only makes sense when a unique child exists. Therefore, the relationship should be one-to-one or many-to-one.
- If your current post is in a relationship acting as an intermediary post, you can use the value of @{relationship-slug}.child to obtain data from the related child. Note that this only makes sense when an intermediary post exists, which happens only in many-to-many relationships.
- If your current post is in a many-to-many relationship acting as a parent or child, you can try to determine the intermediary post of a connection with another post by using the value @{relationship-slug}.association. Note that this scenario is open to ambiguity because a single post can have several connections to other posts in this many-to-many relationship, but this attribute value will return only one intermediary post.
- If your current post is in a many-to-many relationship acting as a parent or child and you are displaying it as part of a View loop that includes a query filter by posts relationship, which is used to set the context of the missing parent or child element of the relationship, you can use @{relationship-slug}.intermediary to display data for the defined intermediary post type. This intermediary post is defined by your current post and the one provided as a query-filter value.
- If you use this item attribute with any of the @-starting values and it does not achieve the task of obtaining data from the desired target post, the shortcode will produce no output.
-
-