Get multiple category names from permalink

The function get_category_parents will get you a string of the parent categories given the ID of a child category. So, like this: $cat = $wp_query->get_queried_object(); $catid = $cat->cat_ID; $parentcats = get_category_parents ($catid, false, ‘|’, false); This will give you something like category1|category2|category3. Follow the link above to see what other options you have. If you … Read more

Ordering terms whilst in loop

I just realised I already have the parent from here $category = $_GET[‘category’]; So I changed my code: <td class=”custom-cat”> <span class=”term”> <?php echo $category; ?> </span></td> <td class=”custom-sub-cat”> <span class=”term”> <?php $terms = get_the_terms( get_the_ID(), ‘custom-category’ ); foreach ( $terms as $term ){ if ( $term->parent ==! 0 ) { echo $term->name; } } … Read more