I currently have coded the following:
‘<?php if ( in_category(‘3’) ): ?>
<?php $query=$query_string . ‘&order=ASC’;
<?php endif; ?>’
I want to be able to use this code to ensure that all child categories of one parent category are sorted ASC, while all other categories are DESC.
I can find no way to make this dynamic – in that I can not put the parent category ID in the in_category tag and it work on the child categories. Nor can I find a way to find out if the current category is a child of the parent, and thus change the sort order based on that. I don’t want to have to edit the template every time I introduce a new child category.
Is there a way to interrogate the category and find out the parent category ID, and use it in the code above.?
- The topic ‘Obtaining Parent catagory IDs’ is closed to new replies.