Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1088369

    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:&nbsp"._('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');
    #1088733

    Hey matecra,

    Is it the same categories that you want to exclude or different all the time?

    Best regards,
    Victoria

    #1089085

    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.

    #1090641

    Hi,

    Thank you very much for letting us know – we appreciate it.

    Best regards,
    Basilis

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.