How can I query the db for all the tags associated with an article?

I have been able to use JTable to query to *_tags table, but that doesn't return the tags that are associated with the article record.

I'm interesting in something like:

$tags = JTags::searchByArticleId(1);

1 Answer 1


Use TagsHelper::getItemTags():

use Joomla\CMS\Helper\TagsHelper;

$tags = new TagsHelper;
$tags->getItemTags('com_content.article', $articleId);

Where $articleId is article ID. Tags will be available through $tags->itemTags.

If you already have article object loaded, you can add tags to it:

$article->tags = new TagsHelper;
$article->tags->getItemTags('com_content.article', $article->id);
  • I eventually stumbled on this, but nice to have it confirmed. Thank you.
    – steel
    Jul 20, 2018 at 15:01

Your Answer

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

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