WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
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
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.