Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rajucs/76eae616df91ab01984b8167795e7b1c to your computer and use it in GitHub Desktop.

Select an option

Save rajucs/76eae616df91ab01984b8167795e7b1c to your computer and use it in GitHub Desktop.
<?php
$product_tags = get_terms( 'product_tag');
$i=0;
foreach ( $product_tags as $product_tag ) {
$args = array(
'posts_per_page' => -1,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'product_tag',
'field' => 'slug',
'product_tag' => array('latest-product'),
'terms' => $product_tag->slug,
'terms'=> array('latest-product'),
'post_type' => 'product'
)
),
'orderby' => 'post_type'
);
$products = new WP_Query( $args );
while ( $products->have_posts() ) {
$products->the_post();
?>
<div class="card " style="background-image: url('<?php echo wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); ?>');height: 350px;background-size: 100% 100%;background-repeat: no-repeat;">
<h3 class="text-center"><?php substr(the_title(),0,20); ?></h3>
<a href="<?php the_permalink(); ?>" class="btn btn-inquire"><span>Inquire</span></a>
</div>
<?php $i++; } ?>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment