Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save celticwebdesign/2d859fa8dbd7e852b59b8d654a17d9ec to your computer and use it in GitHub Desktop.
Save celticwebdesign/2d859fa8dbd7e852b59b8d654a17d9ec to your computer and use it in GitHub Desktop.
Used on Treyone
<section class="wrapper full taxonomy-kitchens">
<div class="wrapper narrow collapse">
<?php
$args = array(
'post_type' => 'photo',
'posts_per_page' => '15',
'orderby' => 'rand',
'tax_query' => array(
array(
'taxonomy' => 'kitchens',
'field' => 'id',
'terms' => get_queried_object()->term_id,
),
),
);
$taxonomy_query = new WP_Query( $args );
// $count = $taxonomy_query->post_count;
echo "<div class='term-content clear'>";
echo "<ul class='clear'>";
if ($taxonomy_query->have_posts()) :
while ($taxonomy_query->have_posts()) : $taxonomy_query->the_post();
$attachment_id = get_field( 'single_photo', $taxonomy_query->post->ID);
switch ( get_field( 'photo_display_size', $taxonomy_query->post->ID) ) {
case "Small":
$image_attributes = wp_get_attachment_image_src( $attachment_id, 'taxonomy-small-photo' );
$image_size = 'small';
break;
case "Half":
$image_attributes = wp_get_attachment_image_src( $attachment_id, 'taxonomy-half-photo' );
$image_size = 'half';
break;
case "Medium":
$image_attributes = wp_get_attachment_image_src( $attachment_id, 'taxonomy-medium-photo' );
$image_size = 'medium';
break;
case "Large":
$image_attributes = wp_get_attachment_image_src( $attachment_id, 'taxonomy-large-photo' );
$image_size = 'large';
break;
default:
$image_attributes = wp_get_attachment_image_src( $attachment_id, 'large' );
}
echo "<li class='".$image_size."'>";
$alt_text = get_post_meta($attachment_id , '_wp_attachment_image_alt', true);
echo "<div class='photo ".$image_size."'>
<img src='".$image_attributes[0]."' alt='".$alt_text."'>";
// echo "<div class='listing-content'>";
// $terms = get_the_terms( $taxonomy_query->post->ID, 'kitchens' );
// shuffle($terms);
// if ( $terms && !is_wp_error( $terms ) ) :
// foreach ( $terms as $term ) {
// echo "<div class='term'>
// <a href='".get_term_link( $term->name, 'kitchens' )."' title='".$term->name."'>".$term->name."</a>
// </div>";
// }
// endif;
// echo "</div>";
echo "</div>";
echo "</li>";
endwhile;
endif;
echo "</ul>";
echo "</div>";
?>
</div>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment