Tag Documentation

Tag:Entries template tag

This template tag allows you to display a list of channel entries that contain the tag(s) in the URL, or in the tag parameter. This template is usually a page you would link to from a Tag Cloud or through an entry with the Tag:Tags template tag.

As of Tag 5.x, the Tag:Entries template tag no longer dynamically checks for a tag in the URI. It now just looks at the tag parameter for tag(s). So it's most likely you will call the tag="" parameter with a {segment_3} value to read the tag from a segment now:

{exp:tag:entries tag="{segment_3}"} content {/exp:tag:entries}

Parameters

Most of the parameters available in the Channel:Entries loop are available here. Additionally, these exist as well:

channel_entry_id=

channel_entry_id="not 7|16|46"

This parameter behaves exactly like the the regular EE entry_id parameter. This allows you to filter out or filter down to specific channel entries.

inclusive=

inclusive="yes"

You can pull entries by multiple tags when tags are separated by commas in the URI. If you set this parameter to yes, only entries that contain all of the tags will be shown. Otherwise, the default method just checks to see if any of the tags match.

paginate=

paginate="both"

Pagination works just like it does in the Channel:Entries tag. When specified, and used in conjunction with the tag_paginate variable pair, pagination will display. Refer to Channel:Entries tag documentation for more information.

tag=

tag="{segment_3}"

This parameter is required to display entries that have been assigned the selected tag. You can pass the tag through the URI (most common) or hard code a tag value. If hardcoding, to specify multiple tags, separate tags with the pipe character.

tag_group_id=

tag_group_id="3"

This parameter allows you to narrow down or filter the tag results in the list by specifying the tag group ID. Seperate multiples with the pipe character.

tag_group_name=

tag_group_name="group1|group2"

This parameter allows you to narrow down or filter the tag results in the list by specifying the tag group short name. Seperate multiples with the pipe character.

tag_separator=

tag_separator="_"

This parameter allows you to specify the character that separates multiple tags in the URI, in the event you're calling multiple tags in the URI. Default is comma (,), but if your site is set to force query strings, EE won't let you have commas in the URI.

websafe_separator=

websafe_separator="-"

This parameter allows you to control the websafe separator character for multi-word tags in the URI. Allowable characters are +, -, and _. The default is +. Be sure to use this parameter consistently throughout your site if you change from the default value of +. For example, if you're linking from your Tag cloud to your Tag:Entries page with - as your websafe separator, you'll need to add this same parameter with - as the value for your Tag:Entries page. Otherwise results will NOT show correctly.

Variables

Most of the variables available in the Channel:Entries loop are available here.

Variable Pairs

Most of the variable pairs available in the Channel:Entries loop are available here. Additionally, the following variable pairs are available for use:

tag_paginate

{tag_paginate}
    <li>
        Page {tag_current_page} of
        {tag_total_pages} pages &nbsp;
        {tag_pagination_links}
    </li>
{/tag_paginate}

OR

{tag_paginate}
<ul class="pagination">
    {tag_pagination_links}
        {first_page}
            <li><a href="{pagination_url}">First</a></li>
        {/first_page}
        {previous_page}
            <li><a href="{pagination_url}">&laquo; Previous</a></li>
        {/previous_page}
        {page}
            <li{if current_page} class="active"{/if}><a href="{pagination_url}">{pagination_page_number}</a></li>
        {/page}
        {next_page}
            <li><a href="{pagination_url}">Next &raquo;</a></li>
        {/next_page}
        {last_page}
            <li><a href="{pagination_url}">Last</a></li>
        {/last_page}
    {/tag_pagination_links}
</ul>
{/tag_paginate}

Pagination is available for this tag and works just like regular EE pagination, but each variable/variable pair is prepended with tag_ (except for any variables and variable pairs inside of the tag_pagination_links variable pair). Used in conjunction with the paginate parameter.

Conditionals

In addition to most conditionals available in the Channel:Entries tag, the following conditionals are available for use:

tag_no_results

{if tag_no_results}
    Sorry, no results were found.
{/if}

This conditional displays it's contents when there are no results found.

Examples

The below example will display the title and body of all channel entries associated with the specified tag. Additionally, it will pull the tag name from the URI and “clean it up” using the Tag:Name template tag.

<h1>
    Entries tagged with:
    {exp:tag:tag_name
        tag="{segment_3}"
        case="title"
    }
</h1>

{exp:tag:entries
    tag="{segment_3}"
    inclusive="yes"
    orderby="title" sort="asc"
    limit="20"
    paginate="bottom"
}

    <h2>{title}</h2>
    <p>{body}</p>

    {tag_paginate}
    <ul class="pagination">
        {tag_pagination_links}
            {first_page}
                <li><a href="{pagination_url}">First</a></li>
            {/first_page}
            {previous_page}
                <li><a href="{pagination_url}">&laquo; Previous</a></li>
            {/previous_page}
            {page}
                <li{if current_page} class="active"{/if}><a href="{pagination_url}">{pagination_page_number}</a></li>
            {/page}
            {next_page}
                <li><a href="{pagination_url}">Next &raquo;</a></li>
            {/next_page}
            {last_page}
                <li><a href="{pagination_url}">Last</a></li>
            {/last_page}
        {/tag_pagination_links}
    </ul>
    {/tag_paginate}

{/exp:tag:entries}

Support

Having problems setting up and/or using Tag? Support is offered from 10am to 4pm EST weekdays. Send us an email at help@eeharbor.com and we will respond as quickly as we can.