<txp:tags />

Textpattern tags are arguably the most interesting and important feature of Textpattern. They represent a shorthand method for calling functions defined inside the Textpattern core code.

The functions themselves represent content components, their sources, and means of displaying them. The tags can be added to web pages in a great variety of ways depending on what you are trying to achieve. The tags are replaced with the content output they call as you move from one page to another within your dynamic web site.


Self-closed tags are the most basic form of Texpattern tag, their structure is similar to that of a line break in XHTML <br />.

<txp:tagname />

The tag is replaced by dynamic content when Textpattern displays a page.

Self-closed tags can usually take attributes. For example, the following article tag demonstrates using the form and limit attributes:

<txp:article form="formName" limit="15" />

Outputs articles using form "formName", don't display more than 15 of them.


Container tags are composed of both an opening and closing tag element, their structure is similar to that of an anchor link in HTML <a href="url">link text</a>.

<txp:tag_name> ...content added here... </txp:tag_name>

The content that is added between container tags may be either text or other TXP tags.

Container tags are used when something has to be enclosed by tags instead of being replaced by them. A link is a good example: you have a text string (or a title tag) around which you want to wrap an HTML anchor element.

<txp:permlink><txp:title /></txp:permlink>

Returns the permanent url of the article being displayed.


Similar to (X)HTML, TXP allows you to nest tags within tags, as long as you close them in the correct order (i.e. tag closing cannot overlap).

Indenting is used here to show which tags belong to which bits of contained content. Notice the order in which the tags are openend and closed; it follows standard (X)HTML and XML principles:

<txp:if_section name="archive">
      <h3>Archives in category <txp:category title=1 />:</h3>
   <txp:else />
      <h3>Archives by category:</h3>
<txp:else />
   <h3>Articles by category:</h3>

Is it the archive section, for a particular category or all categories, no it's another section.


Textpattern tags allow you to specify attributes as key/value pairs to override default behaviour.

<txp:category type="image" title="1" /a>

Display categories, of type of image, with titles.

Usage of attributes in Textpattern tags is similar to attributes in HTML.

  • attribute values must always be delimited by double or single quotes.
    * single quotes have special meaning, so use double quotes by default.
  • attribute keys must be lower case.
  • attribute keys can consist of the letters 'a' through 'z' and underscore.
    * first or last character cannot be an underscore.