What is the correct order to display the tag in the template hierarchy?

Which of the following options is the correct order (by priority in use) to display tag in template hierarchy?

  • tag-[slug].php, tag.php, tag-{id}.php, archive.php, index.php
  • tag-{slug}.php, tag-{id}.php, tag.php, archive.php, index.php
  • archive.php, index.php, tag-[slug].php, tag-{id}.php, tag.php
  • tag-{id}.php, tag-[slug].php, tag.php, archive.php, index.php

Discussion

To display a tag archive index page, WordPress uses the following path:

  1. tag-{slug}.php – If the tag’s slug is sometag, WordPress will look for tag-sometag.php.
  2. tag-{id}.php – If the tag’s ID is 6, WordPress will look for tag-6.php.
  3. tag.php
  4. archive.php
  5. index.php

Reference

https://developer.wordpress.org/themes/basics/template-hierarchy/#tag