Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Forked from cdils/customtaxonomyarchives.php
Last active December 10, 2015 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsmith/4475503 to your computer and use it in GitHub Desktop.
Save wpsmith/4475503 to your computer and use it in GitHub Desktop.
add_action( 'genesis_loop', 'cd_custom_taxonomy_archives' );
/**
* Output the taxonomy name and an associated taxonomy image
*/
function cd_custom_taxonomy_archives() {
//print the page title
the_title('<h1 class="entry-title">', '</h1>');
// Code sample modified from example on http://wordpress.mfields.org/plugins/taxonomy-images/
// This filter pulls similar results to get_terms(), except it also includes an image reference
// Only return parent terms
$terms = apply_filters( 'taxonomy-images-get-terms', '', array( 'taxonomy' =>'your-tax-name', 'term_args' => array( 'parent' => 0 ) ) );
foreach( (array) $terms as $term ) {
// div wrapper for portfolio layout
echo '<div class="post-type-archive-portfolio portfolio">';
echo '<h2 class="entry-title"><a href="' . esc_url( get_term_link( $term, $term->taxonomy ) ) . '">'. $term->name. '</a></h2>';
echo '<div class="portfolio-featured-image"><a href="' . esc_url( get_term_link( $term, $term->taxonomy ) ) . '">' . wp_get_attachment_image( $term->image_id, 'portfolio' ) . '</a></div>';
echo '</div>';
}
}
}
@cdils
Copy link

cdils commented Jan 7, 2013

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment