Template Tags and Parameters
Playa comes with a plethora of powerful template tags, each with a host of parameters to fully customize your template output.
Playa Terminology
Before you dive into Playa’s template tags, it’s crucial that you understand the terminology:
- Parent
- The entry that has the Playa field.
- Child
- The entry that you selected in the Playa field.
- Sibling
- An entry that shares at least one parent with another.
- Co-parent
- An entry that shares at least one child with another.
Template Tags at a Glance
Module Tags
{exp:playa:children}{exp:playa:parents}{exp:playa:siblings}{exp:playa:coparents}{exp:playa:total_children}{exp:playa:total_parents}{exp:playa:total_siblings}{exp:playa:total_coparents}{exp:playa:child_ids}{exp:playa:parent_ids}{exp:playa:sibling_ids}{exp:playa:coparent_ids}
Fieldtype Tags
Module Tags
{exp:playa:children}
Returns child entries.
{exp:channel:entries channel="news"}
<h3>Article Media</h3>
<ul>
{exp:playa:children field="article_photos|article_videos"}
<li><a href="{path={channel_short_name}/{url_title}}">{title}</a></li>
{/exp:playa:children}
</ul>
{/exp:channel:entries}
Tag Parameters
{exp:playa:children} supports almost all of {exp:channel:entries}’ tag parameters, as well as the following:
entry_id=-
The parent entry’s ID(s). If your
{exp:playa:children}tag is within an{exp:channel:entries}tag pair, this will default to the current entry’s ID.{exp:playa:children entry_id="1"}This would return all the chilren of an entry with the ID of 1.
{exp:playa:children entry_id="1|2"}This would return all of the children of entries with the IDs of 1 and 2.
{exp:playa:children entry_id="1&&2"}This would return all of the common children of entries with the IDs of 1 and 2. Entries that weren’t related from all of the parents will be ignored.
child_id=- The child entry ID(s) to include. Prefix with “
not” to define entries to exclude instead. field=- The Playa field’s name where the relationship was made, or the Matrix field’s name if your Playa field lives within a Matrix field
field_id=- The Playa field’s ID where the relationship was made, or the Matrix field’s ID if your Playa field lives within a Matrix field
col=- The Matrix column’s name where the relationship was made
col_id=- The Matrix column’s ID where the relationship was made
row_id=- The Matrix row’s ID where the relationship was made
var=- The Low Variables variable’s name where the relationship was made
var_id=- The Low Variables variable’s ID where the relationship was made
Note: Playa sets the disable= tag parameter to “categories|category_fields|member_data|pagination” by default. So if you want to display categories, member data, or pagination tags in your Playa tag pair, you’ll need to override that parameter.
Variable Tags
{exp:playa:children} supports almost all of {exp:channel:entries}’ conditional variables, single variables, and variable pairs, as well as the following:
Conditional Variables
{if no_children} ... {/if}
Single Variables
If your {exp:playa:children} tag pair is within an {exp:channel:entries} tag pair, you can use the following variables to access properties of the main Channel Entries entry:
{parent:author_id}{parent:channel_title}{parent:channel}{parent:channel_id}{parent:channel_short_name}{parent:count}{parent:entry_date}{parent:entry_id}{parent:entry_site_id}{parent:expiration_date}{parent:screen_name}{parent:status}{parent:title}{parent:url_title}
{exp:playa:parents}
Returns parent entries.
{exp:channel:entries channel="photos"}
<h3>As Seen in Articles</h3>
<ul>
{exp:playa:parents channel="articles"}
<li><a href="{path={channel_short_name}/{url_title}}">{title}</a></li>
{/exp:playa:parents}
</ul>
{/exp:channel:entries}
Tag Parameters
{exp:playa:parents} supports almost all of {exp:channel:entries}’ tag parameters, as well as the following:
entry_id=-
The child entry’s ID(s). If your
{exp:playa:parents}tag is within an{exp:channel:entries}tag pair, this will default to the current entry’s ID.{exp:playa:parents entry_id="1"}This would return all the parents of an entry with the ID of 1.
{exp:playa:parents entry_id="1|2"}This would return all of the parents of entries with the IDs of 1 and 2.
{exp:playa:parents entry_id="1&&2"}This would return all of the common parents of entries with the IDs of 1 and 2. Entries that don’t relate to all of the children will be ignored.
parent_id=- The parent entry ID(s) to include. Prefix with “
not” to define entries to exclude instead. field=- The Playa field’s name where the relationship was made, or the Matrix field’s name if your Playa field lives within a Matrix field
field_id=- The Playa field’s ID where the relationship was made, or the Matrix field’s ID if your Playa field lives within a Matrix field
col=- The Matrix column’s name where the relationship was made
col_id=- The Matrix column’s ID where the relationship was made
row_id=- The Matrix row’s ID where the relationship was made
Note: Playa sets the disable= tag parameter to “categories|category_fields|member_data|pagination” by default. So if you want to display categories, member data, or pagination tags in your Playa tag pair, you’ll need to override that parameter.
Variable Tags
{exp:playa:parents} supports almost all of {exp:channel:entries}’ conditional variables, single variables, and variable pairs, as well as the following:
Conditional Variables
{if no_parents} ... {/if}
Single Variables
If your {exp:playa:parents} tag pair is within an {exp:channel:entries} tag pair, you can use the following variables to access properties of the main Channel Entries entry:
{child:author_id}{child:channel_title}{child:channel}{child:channel_id}{child:channel_short_name}{child:count}{child:entry_date}{child:entry_id}{child:entry_site_id}{child:expiration_date}{child:screen_name}{child:status}{child:title}{child:url_title}
{exp:playa:siblings}
Returns sibling entries.
<ul class="photo-nav">
{exp:playa:siblings entry_id="{segment_3}" parent_id="{segment_2}"}
<li><a href="{path={channel_short_name}/{url_title}}">{title}</a></li>
{/exp:playa:siblings}
</ul>
Tag Parameters
{exp:playa:siblings} supports almost all of {exp:channel:entries}’ tag parameters, as well as the following:
entry_id=-
The main entry’s ID(s). If your
{exp:playa:siblings}tag is within an{exp:channel:entries}tag pair, this will default to the current entry’s ID.{exp:playa:siblings entry_id="1"}This would return all the siblings of an entry with the ID of 1.
{exp:playa:siblings entry_id="1|2"}This would return all of the siblings of entries with the IDs of 1 and 2.
sibling_id=- The sibling entry ID(s) to include. Prefix with “
not” to define entries to exclude instead. parent_id=- The parent entry ID(s) that the siblings must have in common. Prefix with “
not” to define entries to exclude instead. field=- The Playa field’s name where the relationships were made, or the Matrix field’s name if your Playa field lives within a Matrix field
field_id=- The Playa field’s ID where the relationships were made, or the Matrix field’s ID if your Playa field lives within a Matrix field
col=- The Matrix column’s name where the relationships were made
col_id=- The Matrix column’s ID where the relationships were made
row_id=- The Matrix row’s ID where the relationships were made
Note: By default, siblings will be ordered by the number of common parents they share with the original entry. You can override that with the orderby= param.
Note: Playa sets the disable= tag parameter to “categories|category_fields|member_data|pagination” by default. So if you want to display categories, member data, or pagination tags in your Playa tag pair, you’ll need to override that parameter.
Variable Tags
{exp:playa:siblings} supports almost all of {exp:channel:entries}’ conditional variables, single variables, and variable pairs, as well as the following:
Conditional Variables
{if no_siblings} ... {/if}
Single Variables
If your {exp:playa:siblings} tag pair is within an {exp:channel:entries} tag pair, you can use the following variables to access properties of the main Channel Entries entry:
{sibling:author_id}{sibling:channel_title}{sibling:channel}{sibling:channel_id}{sibling:channel_short_name}{sibling:count}{sibling:entry_date}{sibling:entry_id}{sibling:entry_site_id}{sibling:expiration_date}{sibling:screen_name}{sibling:status}{sibling:title}{sibling:url_title}
{exp:playa:coparents}
Returns co-parent entries.
{exp:channel:entries}
<h3>Similar entries to “{title}”</h3>
<ul>
{exp:playa:coparents}
<li><a href="{path={channel_short_name}/{url_title}}">{title}</a></li>
{/exp:playa:coparents}
</ul>
{/exp:channel:entries}
Tag Parameters
{exp:playa:coparents} supports almost all of {exp:channel:entries}’ tag parameters, as well as the following:
entry_id=-
The main entry’s ID(s). If your
{exp:playa:coparents}tag is within an{exp:channel:entries}tag pair, this will default to the current entry’s ID.{exp:playa:coparents entry_id="1"}This would return all the co-parents of an entry with the ID of 1.
{exp:playa:coparents entry_id="1|2"}This would return all of the co-parents of entries with the IDs of 1 and 2.
coparent_id=- The co-parent entry ID(s) to include. Prefix with “
not” to define entries to exclude instead. child_id=- The child entry ID(s) that the co-parents must have in common. Prefix with “
not” to define entries to exclude instead. field=- The Playa field’s name where the relationships were made, or the Matrix field’s name if your Playa field lives within a Matrix field
field_id=- The Playa field’s ID where the relationships were made, or the Matrix field’s ID if your Playa field lives within a Matrix field
col=- The Matrix column’s name where the relationships were made
col_id=- The Matrix column’s ID where the relationships were made
row_id=- The Matrix row’s ID where the relationships were made
Note: By default, co-parents will be ordered by the number of common children they share with the original entry. You can override that with the orderby= param.
Note: Playa sets the disable= tag parameter to “categories|category_fields|member_data|pagination” by default. So if you want to display categories, member data, or pagination tags in your Playa tag pair, you’ll need to override that parameter.
Variable Tags
{exp:playa:coparents} supports almost all of {exp:channel:entries}’ conditional variables, single variables, and variable pairs, as well as the following:
Conditional Variables
{if no_coparents} ... {/if}
Single Variables
If your {exp:playa:coparents} tag pair is within an {exp:channel:entries} tag pair, you can use the following variables to access properties of the main Channel Entries entry:
{parent:author_id}{parent:channel_title}{parent:channel}{parent:channel_id}{parent:channel_short_name}{parent:count}{parent:entry_date}{parent:entry_id}{parent:entry_site_id}{parent:expiration_date}{parent:screen_name}{parent:status}{parent:title}{parent:url_title}
{exp:playa:total_children}
Returns the total number of an entry’s children.
{if "{exp:playa:total_children field="article_photos|article_videos"}"}
<h3>Article Media</h3>
...
{/if}
Tag Parameters
{exp:playa:total_children} supports all of the same tag parameters as {exp:playa:children}.
{exp:playa:total_parents}
Returns the total number of an entry’s parents.
Tag Parameters
{exp:playa:total_parents} supports all of the same tag parameters as {exp:playa:parents}.
{exp:playa:total_siblings}
Returns the total number of an entry’s siblings.
Tag Parameters
{exp:playa:total_siblings} supports all of the same tag parameters as {exp:playa:siblings}.
{exp:playa:total_coparents}
Returns the total number of an entry’s co-parents.
Tag Parameters
{exp:playa:total_coparents} supports all of the same tag parameters as {exp:playa:coparents}.
{exp:playa:child_ids}
Returns a list of an entry’s child IDs.
{embed="includes/_showcase" entry_ids="{exp:playa:child_ids field="article_photos|article_videos"}"}
Tag Parameters
{exp:playa:child_ids} supports all of the same tag parameters as {exp:playa:children}, as well as the following:
delimiter=", "- String used to separate the returned entry IDs (default is “
|”).
{exp:playa:parent_ids}
Returns a list of an entry’s parent IDs.
Tag Parameters
{exp:playa:parent_ids} supports all of the same tag parameters as {exp:playa:parents}, as well as the following:
delimiter=", "- String used to separate the returned entry IDs (default is “
|”).
{exp:playa:sibling_ids}
Returns a list of an entry’s sibling IDs.
Tag Parameters
{exp:playa:sibling_ids} supports all of the same tag parameters as {exp:playa:siblings}, as well as the following:
delimiter=", "- String used to separate the returned entry IDs (default is “
|”).
Fieldtype Tags
The following tags apply to your individual Playa fields. They must be used within an {exp:channel:entries} tag pair. In each of the following examples, replace “favorite_bands” with your actual Playa field’s name.
Primary Tag Pair
Returns the field’s children.
<h4>Favorite Bands</h4>
{favorite_bands show_expired="yes" limit="10"}
<h4><a href="/bands/{url_title}">{title}</a></h4>
<p>{short_desc}</p>
{/favorite_bands}
Tag Parameters
The primary tag pair supports almost all of {exp:channel:entries}’ tag parameters, as well as the following:
child_ids="1|2|3"- The child entry ID(s) to include. Prefix with “
not” to define entries to exclude instead.
Note: Playa sets the disable= tag parameter to “categories|category_fields|member_data|pagination” by default. So if you want to display categories, member data, or pagination tags in your Playa tag pair, you’ll need to override that parameter.
Variable Tags
The primary tag pair supports almost all of {exp:channel:entries}’ conditional variables, single variables, and variable pairs, as well as the following:
Conditional Variables
{if no_children} ... {/if}
Single Variables
{parent:author_id}{parent:channel_title}{parent:channel}{parent:channel_id}{parent:channel_short_name}{parent:count}{parent:entry_date}{parent:entry_id}{parent:entry_site_id}{parent:expiration_date}{parent:screen_name}{parent:status}{parent:title}{parent:url_title}
:ul and :ol Tags
Returns an (un)ordered list of the field’s children’s titles.
<h4>Favorite Bands</h4>
{favorite_bands:ol show_expired="yes"}
:total_children Tag
Returns the total number of the field’s children.
<p>I have {favorite_bands:total_children show_expired="yes"} favorite bands.</p>
Note: If you’re going to use the :total_children tag in a conditional, you need to wrap the tag in quotes, e.g. {if "{favorite_bands:total_children}"}. Otherwise you’ll get a PHP parsing error if there are no selected children.
:child_ids Tag
Returns a list of the field’s children’s entry IDs.
{embed="site/child_entries" child_ids="{favorite_bands:child_ids}"}
Tag Parameters
delimiter=", "- String used to separate the returned entry IDs (default is “
|”). backspace="2"- Strip the last X characters from the tag output