Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
foreach((get_the_category()) as $cat) {
if (!($cat->cat_name=='Featured')) echo $cat->cat_name . ' ';

this is what has been recommended in the forums but its not working for me. I need to split off the echo piece like the following to show an image.

<li><img src="<?php bloginfo('template_url'); ?>/images/cats/<?php echo $category->slug ?>-icon.png"/>  <?php  echo $category->cat_name ?> </li>

any ideas?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Try this:

foreach((get_the_category()) as $cat) {
    if ($cat->cat_name != 'Featured') {
        echo '<li><img src="' . get_bloginfo('template_url') . '/images/cats/' . $cat->slug . '-icon.png"/>' . $cat->cat_name . '</li>';
share|improve this answer

Your Answer


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.