Go to main content




<txp:category2 />

The category2 tag can be used as either a single tag or container tag. It will display the category as defined by Category 2 in the article being displayed. When used as a container tag, it will turn the contents into a link to that category. Otherwise, it will return plain text.

This tag may be used within either an article form, or in a page, wrapped in an if_individual_article conditional tag.


Tag will accept the following attributes (case-sensitive) as well as the global attributes :

Whether to link to articles from the same category. Works only in the single tag.
Values: 0 (no) or 1 (yes).
Default: 0.
section="section name" v4.0.4+
Restrict to articles from specified section(s).
Values: (comma separated list of) section name(s).
Default: unset, retrieves from all sections.
Whether to output category title, rather than name.
Values: 0 (no, use name) or 1 (yes, use title).
Default: 0.
this_section="boolean" v4.0.4+
Whether to only link to articles from the section containing the current article.
Values: 0 (no, allow from any section) or 1 (yes).
Default: 0.


Example 1: Category name in plain text

    <txp:category2 />

Example 2: Hyperlinked category title

    <txp:category2 link title />

If category2 is defined with a title ‘Security advice’, this tag will display the words ‘Security advice’ as a hyperlink to a list of articles in the same category.

<txp:category2 wraptag="p">Other articles in category:
<txp:category2 title /></txp:category2>

Might display this HTML:

    <a rel="tag" href="https://example.com/category/security-advice/">
        Other articles in category: Security advice

Example 4: Category 1 and 2

    Filed in: <txp:category1 link title />
    <txp:if_article_category number="2">
        and <txp:category2 link title />

Shows a hyperlinked category 1, and also hyperlinked category 2 but only if it is used.

Other tags used: category1, if_article_category.


Version 4.0.4

class, section, this_section and wraptag attributes added.

If you notice any kind of problem with this page's construction or content (outdated information, typos, broken links, or whatever), open an issue to have it sorted. Or have a go at it yourself. :)