Custom Taxonomies but with Icons associated?

Can I have custom taxonomies but with icons associated with them?

Example: I want a list of skills I used for my portfolio item (eg. PHP, MySQL, CSS etc).
Instead of text, I thought of displaying icons.

Read More

So I needto somehow set icons for my taxonomies.

How might I do it?
Is it very complex?
How might it look or whats it like to build it?
the steps?

Related posts

Leave a Reply

5 comments

  1. I would just build it into your theme, and have the icons stored in your theme folder.

    When you show them on the front end, just check for the icon image instead of showing the terms:

    foreach( $terms as $term ) {
    
        if( file_exists( TEMPLATEPATH . 'images/' . $term->slug . '.png' )
            //show image
    }
    

    If you did need it to be uploaded through the WP-Admin, then you can hook into the edit term page and add another form field:

    add_action( 'my_taxonomy_edit_form_fields', 'my_callback_function_to_show_upload' );
    

    If you did use the above method, you would also have to change the “enc-type” of the form.

  2. You can do it this way, based on @joehoyle’s answer. Well, this has to be adapted to your theme template.

     <?php  
         $terms = get_the_terms( $post->ID, 'custom_cat' ); 
         $numcat=sizeof( $terms );  
         foreach ( $terms as $term ) {
             $term_link = get_term_link( $term, 'custom_cat' );  
             if( file_exists( TEMPLATEPATH .'/images/'. $term->slug .'.png' ) ) { ?>    
                 <a rel="tag" href="<?php echo $term_link; ?>">
                     <img 
                         title="<?php  echo $term->name ;?>" 
                         style="height: 21px; width: 21px;" 
                         src="<?php 
                                  echo get_template_directory_uri() .
                                  '/images/' .
                                  $term->slug .
                                  '.png'
                              ?>" 
                         alt="<?php  echo $term->name; ?>"
                     >
                 </a>
                 |  
             <?php } else { ?>  
                 <a rel="tag" href="<?php echo $term_link; ?>">
                     <?php  echo $term->name; ?>
                 </a>
                 |  
            <?php }
        }
    ?>