Hello there,
i want to display all assigned categories of a portfolio entry.
I’ve found that snipped, which is working very well. But i have to exclude some categories.
Is it possible to extend this snipped with a list of category-ids to be excluded?
Thank you very much…
function avs_custom_categories_shortcode() {
$terms = get_the_terms( get_the_ID(), 'portfolio_entries' );
$output = "Produkt-Kategorie: "._('Kategorie: ', 'avia_framework')."";
foreach ( $terms as $term ) {
// The $term is an object, so we don't need to specify the $taxonomy.
$term_link = get_term_link( $term );
// If there was an error, continue to the next term.
if ( is_wp_error( $term_link ) ) {
continue;
}
// We successfully got a link. Print it out.
$output .= '<a href="' . esc_url( $term_link ) . '">' . $term->name . '</a>';
}
return $output;
}
add_shortcode('the_post_categories', 'avs_custom_categories_shortcode');
Hey matecra,
Is it the same categories that you want to exclude or different all the time?
Best regards,
Victoria
Hi Victoria,
thank you for your reply.
There are always the same categories that I would like to exclude.
A hard coded comma-separated list will probably do.
Hi,
Thank you very much for letting us know – we appreciate it.
Best regards,
Basilis