Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In my loop I've added:

<?php
$categories = get_the_category();
$separator = ' ';
$output = '';
if($categories){
    foreach($categories as $category) {
        $output .= '<span class="post-category-info"><a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a></span>'.$separator;
    }
echo trim($output, $separator);
}
?>

to display all the categories attached to the post here.

There is a specific category "Featured" that I want to prevent from displaying.

I've tried :

<?php
$categories = get_the_category();
$separator = ' ';
$output = '';
if($categories){
    foreach($categories as $category) {
if($category !== 'Featured'){
        $output .= '<span class="post-category-info"><a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a></span>'.$separator;}
    }
echo trim($output, $separator);
}
?>

But I guess it's a wrong approach since it's not working :)

Can anyone please help to achieve my task or at least point me in the right direction? :)

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

$category is an object containing member variables, you have to check the specific member var you want to compare.

change:

if($category !== 'Featured')

to:

if($category->name !== 'Featured')
share|improve this answer
    
Woot it worked! going to select this as a correct answer in a 5 min when the system will allow me to :) –  Acidon Jun 14 '13 at 16:38
    
thank you again! –  Acidon Jun 15 '13 at 4:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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