0

the code I'm currently using to display categories is <?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' ';}?>

I would like to exclude a category called "home-featured" or the category with ID "65" how would I add this to the code above?

0

You could do it like this:

<?php
$exclude = array( 'home-featured' );
foreach( get_the_category() as $category ) {
    if ( ! in_array( $category->cat_name, $exclude )
        echo $category->cat_name . ' ';
}
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.