WP Post specific categories with excluded category

<?php $categories = get_the_category(); $separator = ' '; $output = ''; if($categories){ foreach($categories as $category) { if($category->name !== 'Category name 1') if($category->name !== 'Category name 2') { $output .= '<a href="'.get_category_link( $category->term_id ).'">'.$category->cat_name.'</a>'.$separator; } } echo trim($output, $separator); } ?>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.