Hi,
I found the following function to display portfolio categories on a portfolio item:
function show_portfolio_category_func() {
global $post;
$the_terms = get_the_terms( $post->ID , ‘portfolio_entries’);
$output = ”;
foreach($the_terms as $term) {
$termlink = get_term_link($term->term_id, $term->taxonomy);
$output .= ‘<span class=”portfolio_cat”>‘.$term->name.’ </span>’;
}
return $output;
}
add_shortcode(‘portfolio_category’, ‘show_portfolio_category_func’);
How do I modify this to ONLY show categories within the Parent Category “Habitats”?
If you look in private content and scroll to the bottom, you can see the portfolio categories listed – I like this but want to remove the categories that are not part of the Habitats parent category.
Thanks for your help as always!
Hey connect4consulting,
You can check if the portfolio has the term and run the code only then.
Here are the docs for you:
Best regards,
Victoria
Hi Victoria,
Thanks for your help! I’m sorry but I don’t understand.
In this scenario, I want to only show the parent category for “habitats” but I have another scenario where I only want to show the parent category “features”. In both situations, it’s a parent category, however.
I want to be able to use a shortcode and display the types of habitats of each portfolio item and then another shortcode to display all of the features of each portfolio item – in two different spots on the page.
The category ID for habitats is 218.
The category ID for features is 248.
Thanks so much!
Hi,
Sorry for the late response. We replied in the other thread.
// https://kriesi.at/support/topic/how-do-i-show-portfolio-categories-on-a-portfolio-item/#post-1155473
Please continue there so that we can close this one. Thank you for your patience.
Best regards,
Ismael