I'm looking to create tags programmatically. I've done it through a direct DB insert but that doesn't seem to be working correctly as I can't associated those created tags with a piece of content via the observer.

I'm looking for something like this:

$content = JTable::getInstance("Content", 'JTable', array());
JHelperTags::addTags(array("tag1", "tag2"), $content);

JHelperTags has a method that may do what I want, but I don't understand the arguments. The following does not work

$h = new JHelperTags();
$h->tagItem($content->id, $content, array("tag1", "tag2"));

How can I programmatically create tags that will be correctly stored in Joomla?

1 Answer 1


I was able to use createTagsFromField. #new# has to be appended to the title if the tag doesn't exist.

$title = "Tag Title";
$h = new JHelperTags;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.