WordPress.org

Ready to get started?Download WordPress

Forums

Categories Images
[resolved] List images with links (1 post)

  1. superpotion
    Member
    Posted 1 year ago #

    Thought you might find this useful: a function to output a list of category (or term) images with links. I use it inside the PHP widget plugin to get a clickable list of category images.

    function z_list_taxonomy_images($taxonomy = "category") {
    
    	$args=array(
    	  'orderby'  => 'name',
    	  'order'    => 'ASC',
    	  'taxonomy' => $taxonomy
    	  );
    
    	$terms=get_categories($args) ;
    
    	if (count($terms)>0) {
    
    		$html = '<ul class="z_list_taxonomy_images">' . "\n" ;
    		foreach($terms as $term) {
    			$html .= '   <li>' . "\n";
    			$html .= '      <a href="' . get_term_link(intval($term->term_id), $term->taxonomy) . '" title="' . $term->name . '">';
    			$html .= '         <img src="' . z_taxonomy_image_url($term->term_id) . '" />';
    			$html .= '      </a>' . "\n";
    			$html .= '   </li>' . "\n";
    		}
    		$html .= '</ul>' . "\n";
    
    	} else {
    
    		$html = '<p>' . "Taxonomy " . $taxonomy . " not found.</p> \n" ;
    	}
    
    	echo $html ;
    }

    Simply include the code in your (child) theme's functions.php or modify the plugin directly (I used the author's function naming convention for this reason).

    Enjoy

    Denis

    http://wordpress.org/extend/plugins/categories-images/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.