Created
November 21, 2019 20:34
-
-
Save imagebox/a60d666d409c58571cd755afdaeb171b to your computer and use it in GitHub Desktop.
[facetwp woocommerce product category query]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="l-main-col"> | |
<table class="parts-table"> | |
<tbody class="facetwp-template"> | |
<?php | |
$termid = get_queried_object()->term_id; | |
$args = array( | |
'post_type' => 'product', | |
'posts_per_page' => 18, | |
'facetwp' => true, | |
'paged' => $paged, | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'product_cat', | |
'field' => 'term_id', | |
'terms' => $termid | |
) | |
) | |
); | |
?> | |
<?php $loop = new WP_Query( $args ); | |
if ( $loop->have_posts() ) { | |
while ( $loop->have_posts() ) : $loop->the_post(); ?> | |
<tr> | |
<td class="table-title-sku"> | |
<h4><a href="<?php the_permalink();?>"> | |
<?php the_title();?> | |
</a></h4> | |
<?php | |
$product_id = $post->ID; | |
$product = wc_get_product( $product_id ); | |
$product_sku = $product->get_sku(); | |
if( !empty($product_sku) ) : | |
echo '<div class="part-sku"><strong>SKU:</strong> '; | |
echo $product_sku; | |
echo '</div>'; | |
endif; | |
?> | |
</td> | |
<td class="table-call-note"> | |
<a href="<?php the_permalink();?>"> | |
<?php _e('Call for price and availability: 724-863-7000'); ?> | |
</a> | |
</td> | |
</tr> | |
<?php endwhile; | |
} else { | |
echo __( 'No products found' ); | |
} | |
wp_reset_postdata(); | |
?> | |
</tbody> | |
</table> | |
<?php echo do_shortcode('[facetwp pager="true"]'); ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment