Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Printing related articles to parent category
Hello, I need to print the related articles of the parent category, when viewing an article.
This is my category tree, with item number between brackets:
Parent (0)
child01 (6)
child02 (2)
So when viewing a child02 article, I need to print the child01 and child02 related articles.
Thank you very much
Offline
Re: Printing related articles to parent category
The general steps:
- get the parent category for the current article; can use smd_parent for this
- make a category_list based on the parent
- use the category list as the basis for an article_custom list
This gets more complicated if you need to allow for the article having this child category as either its category1 or its category2. I’ll assume category1 only (untested code):
<txp:article_custom category='<txp:category_list parent='<txp:smd_parent catnum="1" />' break=","><txp:category /></txp:category_list>'>
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
Code is topiary
Offline