Skip to content

Instantly share code, notes, and snippets.

@ejntaylor
Last active January 1, 2016 05:08
Show Gist options
  • Select an option

  • Save ejntaylor/8096034 to your computer and use it in GitHub Desktop.

Select an option

Save ejntaylor/8096034 to your computer and use it in GitHub Desktop.
List Categories within tag ** Need to replace Catgeory shortcode with another loop which filters products out which are not in current product_tag
<?php $product_tag = (get_query_var('product_tag')) ? get_query_var('product_tag') : 1; ?>
<h1>Currently Browsing: <?php echo $product_tag; ?></h1>
<?php
$args = array(
'number' => $number,
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
'include' => $ids
);
$product_categories = get_terms( 'product_cat', $args );
echo '<ul class="tag-cat">';
foreach( $product_categories as $cat ) {
$tag_cat = do_shortcode('[product_category category="'. $cat->slug .'" per_page="30" columns="8" orderby="date" order="desc"]');
if(($tag_cat != '<div class="woocommerce"></div>')) {
echo '<li class="tag-group">';
echo '<ul class="tagged">';
echo '<h2>';
echo $cat->name;
echo '</h2>';
echo $tag_cat;
echo '</ul>';
echo '</li>';
}
}
echo '</ul>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment