Art Gallery using Custom Post Type and Custom Taxonomy
-
I’m working on a website for an artist. I have created a CPT called “artwork” and custom taxonomies for the attributes of each piece of work. One of the custom taxonomies is “album” which supports a hierarchy so that a user can navigate through the gallery. It is working somewhat here if you click on “2014” and then “Flowers”. What I’m missing is a thumbnail image for each folder that is pulled from the actual artwork (grandchild of parent term). Here is my code from the taxonomy-album.php file:
<?php get_header(); ?> <div class="container clearfix"> <header class="entry-title"> <h1 class = "archive-title"><?php single_cat_title(); ?></h1> </header> <h3 class = "category_description"><?php echo category_description(); ?> </h3> <div class = "taxonomy_thumbnails"> <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); // get current term $parent = get_term($term->parent, get_query_var('taxonomy') ); // get parent term $children = get_term_children($term->term_id, get_query_var('taxonomy')); // get children if(($parent->term_id!="" && sizeof($children)>0)) { // set the args for wp_list_categories $args = array( 'child_of' => $term->term_id, 'taxonomy' => $term->taxonomy, 'order' => DESC, 'hide_empty' => 0, 'hierarchical' => true, 'depth' => 1, 'title_li' => '' ); wp_list_categories( $args ); }elseif(($parent->term_id!="") && (sizeof($children)==0)) { ?> <div class = "archive_thumbnail_box"> <?php $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ); echo '<a href="' . $large_image_url[0] . '">'; the_post_thumbnail( 'thumbnail' ); echo '</a>'; ?> <span><?php echo get_the_title(); ?></span> </div><!-- .archive_thumbnail_box --> <?php }elseif(($parent->term_id=="") && (sizeof($children)>0)) { // set the args for wp_list_categories $args = array( 'child_of' => $term->term_id, 'taxonomy' => $term->taxonomy, 'order' => DESC, 'hide_empty' => 0, 'hierarchical' => true, 'depth' => 1, 'title_li' => '' ); wp_list_categories( $args ); } ?> </div> <!-- end of .taxonomy_thumbnails --> </div> <!-- end of container --> <?php get_footer(); ?>
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Art Gallery using Custom Post Type and Custom Taxonomy’ is closed to new replies.