Textpattern CMS Template Tags

<txp:recent_articles /> single tag, 5 attributes

recent_articles

The recent_articles tag is a single tag which is used to produce a list of permanent links to recent articles by title.

attributes

section="unset" 
  • Restrict to articles from specified section(s).
  • Values: (comma separated list of) section name(s).
category="unset" 
  • Restrict to articles from specified category/ies. Note: category names may be different to the Title you typed when you created the category. Check the Categories tab to ensure you are using the correct names.
  • Values: (comma separated list of) category name(s).
sort="Posted desc" 
  • Values
    • ID (article id#)
    • Posted (date posted)
    • Expires (expiry date)
    • AuthorID (author name)
    • LastMod (date last modified)
    • LastModID (author name of last modification)
    • Title
    • Image (article image id#)
    • Category1
    • Category2
    • comments_count
    • Status
    • Section
    • Keywords
    • url_title
    • custom_1 through custom_10
      • Note: Each field in the “textpattern” table can be used as a sort key.
    • rand() (random)
  • Direction
    • asc (ascending)
    • desc (descending)
limit="10" (integer) 
  • Number of articles to display.
no_widow="Whatever is set in Advanced Preferences" (boolean)
  • Whether to inhibit line breaks in titles which would leave just a single word on the last line (widows).
  • Values: 0 single words allowed; 1 single words not allowed on their own line

presentation

label="Recent Articles" 
  • Label prepended to item (or as first list item, where appropriate).
  • if wraptag is available and is set to ol or ul, the label will be the first list item.
labeltag="unset" 
  • (X)HTML tag (without brackets) to wrap around label.
break="br" 
  • (X)HTML tag (without brackets) or string to separate list items.
wraptag="unset" 
  • (X)HTML tag (without brackets) to wrap around the list.
class="recent_articles" 
  • (X)HTML class attribute to apply to the wraptag.

genealogy

Version 4.0.6

  • support added for comma separated lists for section and category attributes
<txp:recent_articles /> 3 examples

Labeled list of recent articles

<txp:recent_articles label="Latest and Greatest" limit="5" />

List of recent articles by category

<txp:recent_articles label="Latest" break="br" wraptag="p" category="code" sort="Section desc" />

Styled recent article list

<txp:recent_articles label="Recently" break="li" wraptag="ul" /> 

Styles could go this way

.recent_articles {
     list-style-type:none;
}