Skip to content

Instantly share code, notes, and snippets.

@vladi160
Created July 2, 2021 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladi160/95482d15a42285075ff4e29133f287f2 to your computer and use it in GitHub Desktop.
Save vladi160/95482d15a42285075ff4e29133f287f2 to your computer and use it in GitHub Desktop.
<?php
$taxonomyTypes = get_terms(['taxonomy' => 'product_types']);
if($taxonomyTypes){
foreach( $taxonomyTypes as $taxonomyType ) {
$taxonomyNames = get_terms( array(
'orderby' => 'name',
'order' => 'ASC',
'taxonomy' => 'product_names',
'hide_empty' => true,
'field' => 'slug',
'meta_value' => $taxonomyType->term_id,
'meta_compare' => '=',
) );
if($taxonomyNames){ ?>
<div class="ct-section-inner-wrap">
<h3 class="ct-headline h3-h3"><?php echo $taxonomyType->name ?></h3>
</div>
<div class="rb_products">
<?php
foreach( $taxonomyNames as $taxonomyName ) {
$id = $taxonomyName->term_id;
$fieldKey = 'term_' . $id;
$image = get_field('product_image_1', $fieldKey);
$url = esc_url( get_category_link( $id ) );
?>
<div class="rb_product">
<div class="rb_product_image">
<a class="oxy-post-image" style="background-image: url(<?php echo $image ?>);" href="<?php echo $url; ?>"></a>
</div>
<div class="rb_product_title">
<a href="<?php echo $url; ?>"><?php echo $taxonomyName->name; ?></a>
</div>
</div>
<?php } ?>
</div>
<?php }
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment