Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php get_header(); ?>
- <div class="container clearfix">
- <header class="entry-title">
- <h1 class = "archive-title"><ul class = "gallery_breadcrumb"><?php be_taxonomy_breadcrumb(); ?></ul></h1>
- </header>
- <?php if (category_description( $category ) == '') : ?>
- <?php else : ?>
- <?php echo category_description( $category ); ?>
- <?php endif; ?>
- <?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)) {
- $term_children = get_terms(
- 'album',
- array(
- 'parent' => get_queried_object_id(),
- 'order' => 'DESC',
- )
- );
- if ( ! is_wp_error( $terms ) ) {
- foreach ( $term_children as $child ) {
- // get one random post in this child term
- $random_term_post = get_posts( array(
- 'posts_per_page' => 1, // only one post
- 'orderby' => 'rand', // selected randomly
- 'tax_query' => array(
- array(
- 'taxonomy' => 'album', // from this child album
- 'terms' => $child->term_id
- )
- )
- ) );
- echo '<a href="' . get_term_link( $child ) . '">
- <div class = "taxonomy_thumbnails">';
- echo get_the_post_thumbnail( $random_term_post[0], 'thumbnail' ); // show the random post's thumbnail
- echo '<p>' . $child->name .' </p>';
- echo '</div> <!-- .taxonomy_thumbnails -->';
- echo '</a>';
- }
- }
- }elseif(($parent->term_id!="") && (sizeof($children)==0)) {
- if ( have_posts() ) : while ( have_posts() ) : the_post();
- $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );
- echo '<div class = "taxonomy_thumbnails">';
- echo '<a href="' . $large_image_url[0] . '">';
- echo the_post_thumbnail( 'thumbnail' );
- echo '</a>';
- echo '<p class = "artwork_info"><span style="font-weight:bold; font-style:italic;">'; echo get_the_title(); echo '</span>';
- $year_as_text = strip_tags( get_the_term_list( $wp_query->post->ID, 'year-of-piece', ' · ', ', ', '' ) );
- echo $year_as_text;
- echo '</p>';
- $medium_as_text = strip_tags( get_the_term_list( $wp_query->post->ID, 'medium', '', ', ', '' ) );
- echo $medium_as_text;
- $size_as_text = strip_tags( get_the_term_list( $wp_query->post->ID, 'size', ' · ', ', ', '' ) );
- echo $size_as_text;
- echo '</div><!-- .taxonomy_thumbnails -->';
- endwhile; else : ?>
- <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
- <?php endif; ?>
- <?php
- }elseif(($parent->term_id=="") && (sizeof($children)>0)) {
- $term_children = get_terms(
- 'album',
- array(
- 'parent' => get_queried_object_id(),
- 'order' => 'DESC',
- )
- );
- if ( ! is_wp_error( $terms ) ) {
- foreach ( $term_children as $child ) {
- // get one random post in this child term
- $random_term_post = get_posts( array(
- 'posts_per_page' => 1, // only one post
- 'orderby' => 'rand', // randomly selected
- 'tax_query' => array(
- array(
- 'taxonomy' => 'album', // from this child album
- 'terms' => $child->term_id
- )
- )
- ) );
- echo '<a href="' . get_term_link( $child ) . '">
- <div class = "taxonomy_thumbnails">';
- echo get_the_post_thumbnail( $random_term_post[0], 'thumbnail' ); // show the random post's thumbnail
- echo '<p>' . $child->name .' </p>';
- echo '</div> <!-- .taxonomy_thumbnails -->';
- echo '</a>';
- }
- }
- }
- ?>
- </div> <!-- end of container -->
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement