Hello. Anyone know the proper syntax to pull a list of woocommerce product_tag IDs in a similar fashion as this but as an “else if”
if ( is_archive() ) {
$ids = array();
$cat = get_query_var(‘product_cat’);
$args = array( ‘post_type’ => ‘product’, ‘product_cat’ => $cat );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product;
$ids[] = $loop->post->ID;
Thanks a bunch!
Tried this as my else if, but to no avail:
else if ( is_product_tag() ) {
$ids = array();
$tag = get_terms('product_tag');
$args = array( 'post_type' => 'product', 'product_tag' => $tag );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product;
$ids[] = $loop->post->ID;