Is it possible to create a tag.php
template that when you navigate to the url www.domain.com/tag/architecture/
it will display all the custom posts that have been tagged with that specific tag? And so on for various other tags?
What code will I need to include on my template?
Yes You can create,below is the code i used to display custom post type “knowledge”
This will help you understand hierarchy of templates:
Use of $query_string (example) available here:
According to the template hierarchy, you can create a file called
tag.php
which will be used instead ofindex.php
if a tag page is displayed. You can also prepare separate templates for specific tags.The best way is to start by creating a copy of your theme’s
index.php
and calling ittag.php
, this way you’ll have some basic code working. Then you can modifytag.php
to fit your needs – probably by editing The Loop, or maybe changing some includes if your theme loads the loop from separate file. (but in this case you should consider editingindex.php
to load some other loop for tag pages –is_tag()
may come in handy)