<p>If you have <code>$entry</code>, you should be able to get the tags by the field name, (<code>codes</code>, in your case). </p>

<pre><code>$tags = $entry-&gt;codes;
foreach($tags as $tag)
{
    echo "&lt;li&gt;".$tag-&gt;title."&lt;/li&gt;";
}
</code></pre>

CC BY-SA 3.0
2015-04-21T00:36:27.020Z
2015-04-21T00:36:27.020Z
Aaron Berkowitz
<p>I'm trying to find a way to get tag data from a Model. Currently, I have a template that makes use of tags in an entry like this:</p>

<pre><code>Codes: {% for tag in entry.codes %} {{ tag.title }}; {% endfor %}
</code></pre>

<p>When I create this template, I also need to send some of the data (specifically this data) to an API. Assuming I have an <code>$entry</code> object, how do I iterate through the tags that I need, or get an array with all the tags associated with an entry?</p>

<plugin-development><tags><models>
Getting an entry's tags
# Getting an entry's tags

(Asked by: username_0 on 2015-04-20)

I'm trying to find a way to get tag data from a Model. Currently, I have a template that makes use of tags in an entry like this:
Codes: {% for tag in entry.codes %} {{ tag.title }}; {% endfor %}

When I create this template, I also need to send some of the data (specifically this data) to an API. Assuming I have an $entry object, how do I iterate through the tags that I need, or get an array with all the tags associated with an entry?

**Tags:** plugin-development, tags, models

---

## 1 answers

### Answer by username_1 on 2015-04-21. Score: 2 | Accepted answer

If you have $entry, you should be able to get the tags by the field name, (codes, in your case). 
$tags = $entry->codes;
foreach($tags as $tag)
{
    echo "".$tag->title."";
}


---

