Search

How to Add XenForo Tag Links to Thread List?

  • Thread starter CampFireJack
  • Start date
CampFireJack

CampFireJack

Member
Joined
May 9, 2021
Messages
118
Reaction Score
1
Points
16
  • #1
I use tags extensively on my XenForo forum and I would like to add tag links to the thread lists on forum pages. How can I set this up? Which templates do I need to edit? What code do I need to add? Thanks.
 
CaptainDan

CaptainDan

Member
Joined
May 9, 2021
Messages
113
Reaction Score
0
Points
16
  • #2
On many XenForo forums, I've seen what you would like to do. It's a popular request. While I'm not sure how well tags do anymore as far as search engine optimization goes, they can surely help when it comes to helping visitors navigate your site. This is especially true on larger forums where locating information can be troublesome. With tags, all those threads can be categorized very nicely. It's such a shame that they're so frowned upon by the search engines these days. I used to own a few websites on which I used tags. They did nothing for me and actually drove down my search rankings from the moment I began using them, so be very careful how you go about adding them to your pages. They can spiral out of control easily.

Here's what they'll look like on your thread list (forum) pages:

xenforo-tags-thread-list.gif

Anyway, enough of my preaching. To answer your question, you'll need to edit the THREAD_LIST_MACROS template. You'll add the following code at line 183:

Code:
<xf:if is="$thread.tags">
<li>
<i class="fa fa-tags" aria-hidden="true" title="{{ phrase('tags')|for_attr }}"></i>
<span class="u-srOnly">{{ phrase('tags') }}</span>
<xf:foreach loop="$thread.tags" value="$tag">
<a href="{{ link('tags', $tag) }}" class="tagItem" dir="auto">{$tag.tag}</a>
</xf:foreach>
</li>
</xf:if>

A pared down version is below:

Code:
<xf:if is="$thread.tags">
<li>
<xf:foreach loop="$thread.tags" value="$tag">
<a href="{{ link('tags', $tag) }}" class="tagItem" dir="auto">{$tag.tag}</a>
</xf:foreach>
</li>
</xf:if>

The second option doesn't include the little tag icon before the tag list.

Let me know if this helps.
 
Top