Skip to content

Instantly share code, notes, and snippets.

@chrdesigner
Last active December 21, 2015 13:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrdesigner/6312861 to your computer and use it in GitHub Desktop.
Save chrdesigner/6312861 to your computer and use it in GitHub Desktop.
<?php
function chr_get_taxonomy_image_url($catID, $size=false){
global $_wp_additional_image_sizes;
if (function_exists('z_taxonomy_image_url') && z_taxonomy_image_url($catID) !== false) {
$img_url = z_taxonomy_image_url($catID);
if(empty($img_url)) return false;
$name = substr( $img_url, 0, strrpos( $img_url, '.' ) );
$ext = substr ($img_url, strrpos( $img_url, '.' ) + 1 );
if(is_array($size)){
$name .= '-' . $size[0] . 'x' . $size[1];
}
elseif($_wp_additional_image_sizes[$size]){
$name .= '-' . $_wp_additional_image_sizes[$size]['width'] . 'x' . $_wp_additional_image_sizes[$size]['height'];
}
return $name . '.' . $ext;
}
}
?>
<ul>
<?php foreach (get_terms('SLUG-CATEGORY/TAXONOMY', array('hide_empty' => 0, 'order' => 'ASC', 'orderby' => 'title', 'parent' => 0) ) as $cat) : ?>
<li>
<a href="<?php echo get_term_link($cat->slug, 'SLUG-CATEGORY/TAXONOMY'); ?>" title="<?php echo $cat->name; ?>">
<img src="<?php echo chr_get_taxonomy_image_url($cat->term_id,'NOME-DO-TAMANHO-PERSONALIZADO'); ?>" />
</a>
</li>
<?php endforeach; ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment