Textpattern tips, tutorials and code snippets

Child category article list

Here is a simple tip for creating an article list on a category page that shows not only articles in that category, but also articles in child categories.

Note that you need at least version 4.07 of Textpattern in order for the code to work.

The code

<txp:article_custom category='<txp:category_list parent=''<txp:category />'' break=""><txp:category /><txp:if_last_category><txp:else />,</txp:if_last_category></txp:category_list>' />

Place this code in your page template where you want the list of articles from your child categories to be displayed.

3 Comments Comment feed

  • Joe Hastings
  • 10 May 2009

Very clever indeed. It took me a wee while to work through it but being able to create article lists of parent category and its children is great. How did we live without that before?

Thank you Els

  • Els
  • 18 June 2009

Doh! Too much code ;)

<txp:article_custom category='<txp:category_list parent=''<txp:category />'' break=","><txp:category /></txp:category_list>' />

Easy useful thanks Els!

Add a comment

Use Textile help to style your comments