# Getting tags from post in plugin 'addPostTransformCallback(...)' function?

**URL:** <https://meta.discourse.org/t/getting-tags-from-post-in-plugin-addposttransformcallback-function/83678>\
**Category:** Development\
**Created:** [March 23, 2018, 8:35pm UTC](https://meta.discourse.org/t/getting-tags-from-post-in-plugin-addposttransformcallback-function/83678 "2018-03-23T20:35:33Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Anton](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anton/32/262773_2.png) [@Anton](https://meta.discourse.org/u/Anton)\
**Post date:** [March 23, 2018, 8:35pm UTC](https://meta.discourse.org/t/getting-tags-from-post-in-plugin-addposttransformcallback-function/83678/1 "2018-03-23T20:35:33Z")

</div>

I’m working on a plugin that will transform the output of replies to a topic if there’s a particular tag on the topic itself. I’m doing my mangling in a callback I registered using something like:

```plaintext
api.addPostTransformCallback((transformedPost) => {
/* Do stuff to mangle transformedPost.cooked */
});

```

However, I’m having some trouble getting access to the tags that have been applied to the topic that the post is related to. Currently I’m using

```plaintext
api.includePostAttributes('topic');

```

in the same place I register my callback to include the `topic` object in the list of attributes from the original `post` that was passed into `transform-post.js.es6 :: transformPost(...)`. That lets me do something like:

```plaintext
api.addPostTransformCallback((transformedPost) => {
    if (transformedPost.topic.tags.length > 0) {
        /* Do stuff */
    }
});

```

All I’m accessing from that is the `topic.tags` property. It feels really wrong.

I know the object passed into my callback has access to a `topicId` property, but I’m not sure how to take that and get the list of tags for the topic.

Is there a better way?

---

_[View the full topic](https://meta.discourse.org/t/getting-tags-from-post-in-plugin-addposttransformcallback-function/83678)._
