How to add and remove a Tag in a plugin

AI-generated summary

The discussion revolves around adding and removing a tag in a Discourse plugin. omppatil asks how to achieve this using Discourse functions. twofoursixeight suggests learning the Discourse API, while Arkshine mentions a similar topic, but omppatil clarifies that this topic is related to tags, not flags.

JammyDodger recommends looking at existing plugins, such as the Automation plugin, for examples. merefield points out that posts cannot be tagged, but topics can, and provides an example of tagging a topic. omppatil then asks if there’s a feature similar to tags that can list related posts when clicked.

Hi!,
How can we add a tag to a post, and also remove the tag of the post using the discourse functions?

Hello. Use this to figure out how to use the Discourse API if you don’t understand how to use the Discourse API and wish to learn:

This is actually a duplicated topic. :+1:
I’ve answered him here: How to add and remove a flag for a post in a plugin.

Actually, this is not a duplicate topic as I’ve asked another question on “Flag” and this question is related to “Tag”. I’m trying to use the functions in developing a plugin.

As I’m developing a plugin and I have checked all possible resources, I didn’t find a relevant function that will help me add and remove a tag for the post.

Dev isn’t my strong suit, but there are often examples of how to do things in existing plugins. I think the Automation plugin has a script to add tags based on AI triage. Perhaps looking at that could be helpful?

In general, I’d also recommend including some more detail about what you’ve tried so far/how far you’ve got when asking for dev help. This can help provide context for any answers you might be hoping for.

Just to point out: you can’t Tag a Post.

You can Tag a Topic though.

Which might explain why you couldn’t find an example of the former.

Here’s an example of the latter:

Is there any function or feature that works same as a tag and then by clicking on it will list all those posts?