cat_is_ancestor_of quit working in custom template
-
Hello,
I’ve been using a custom template (via custom functions) for a couple of years that displays certain category names/links in a post if those categories are checked. It suddenly quit working, and I don’t know why (I did just upgrade to WP 3.6 last week).
You can see the custom template here (it’s the Hike At A Glance Box at the top).
In my custom_functions file (the Thesis version of functions.php), I start off my custom template as follows:
/* ****START HIKE AT A GLANCE BOX BEFORE POST**** */ function hike_post_details() { if (in_category('Hike Reviews')) { ?>
I use 2 instances of dynamically displayed categories. Everything else in this custom template displays correctly still (all fed via custom fields, with the exception of these 2 items that are fed via categories).
Best Season uses any season child categories (winter, spring, etc.) of the ancestor “hikes by season” category.
<?php foreach((get_the_category('orderby=ID&order=ASC')) as $childcat) { if (cat_is_ancestor_of(529, $childcat)) { echo $sep . '<a href="'.get_category_link($childcat->cat_ID).'">'; echo $childcat->cat_name; echo '</a>'; $sep = ' '; } } ?>
And Difficulty uses any difficult child categories (easy, moderate, etc.) of the ancestor “hikes by difficulty” category.
<?php foreach((get_the_category('orderby=ID&order=ASC')) as $childcat) { if (cat_is_ancestor_of(114, $childcat)) { echo $sep . '<a href="'.get_category_link($childcat->cat_ID).'">'; echo $childcat->cat_name; echo '</a>'; $sep = ' '; } } ?>
Despite having all of the necessary parent/child categories selected, these fields now appear blank on every single one of my posts.
Like I said, this has worked great for a couple of years, but suddenly quit working. The only change I have made in the last couple of weeks (when they last displayed fine) is upgrading to the most recent version of WordPress.
Any help is appreciated. Thank you!
- The topic ‘cat_is_ancestor_of quit working in custom template’ is closed to new replies.