Skip to content

Instantly share code, notes, and snippets.

@cdils
Last active December 10, 2015 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save cdils/4469782 to your computer and use it in GitHub Desktop.
Save cdils/4469782 to your computer and use it in GitHub Desktop.
I wanted to have a page similar to the Portfolio Archive in the Minimum Theme (http://demo.studiopress.com/minimum/portfolio/). Only catch is that theme is using a CPT archive and I want to populate my page with a custom taxonomy instead. This code is used in a page template and will loop through taxonomy terms (I only want parent tax terms) and…
<?php
add_action( 'genesis_loop', 'cd_custom_taxonomy_archives' );
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
$terms = apply_filters( 'taxonomy-images-get-terms', '', array('taxonomy' =>'your-tax-name') );
foreach( (array) $terms as $term ) {
// Only return parent terms
if ( $term->parent == 0 ) {
$parent = $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 ) ) . '">'. $parent->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>';
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment