Skip to content

Instantly share code, notes, and snippets.

@Ravenna
Created January 9, 2017 19:43
Show Gist options
  • Select an option

  • Save Ravenna/c6bb3ed899a4b4820de2c31529c2e668 to your computer and use it in GitHub Desktop.

Select an option

Save Ravenna/c6bb3ed899a4b4820de2c31529c2e668 to your computer and use it in GitHub Desktop.
if( !function_exists( 'adj_top_cat_page' ) ) {
function adj_top_cat_page( $term_tax_id ) {
$product_cat_id = $term_tax_id;
$children_cat_ids = get_terms( 'product_category', array(
'hide_empty' => false,
'fields' => 'ids',
'child_of' => $product_cat_id
) );
$children_array = array();
if( is_array( $children_cat_ids ) ) {
$i=1;
foreach( $children_cat_ids as $children_cat_id ) {
$products_returned = array();
$args = array();
$child = get_term_by( 'id', $children_cat_id, 'product_category' );
$child_order = $child->term_order;
$child_html = '';
$thumbnail = get_field('child_thumbnail', 'product_category_' . $children_cat_id);
$title = $child->name;
$url = home_url();
$link = ($url . '/products/' . $child->slug);
?>
<div class = "col-sm-3 col-xs-12">
<div class = "category-child-container">
<div class = "category-thumb-container">
<img src = "<?php echo $thumbnail; ?>">
</div>
<a href = "<?php echo $link; ?>" class = "angel-button"><?php echo $title; ?></a>
</div>
</div>
<?php
if ($i % 4 == 0) {
echo ('</div><div class = "row category-child-row">');
$last_row = false;
} else {
$last_row = true;
};
$i++;
};
//foreach
}//if
?>
<div class="col-sm-3 col-xs-12">
<div class="category-child-container">
<div class="category-thumb-container">
<img src="http://www.angeldesignsjewelry.com/wp-content/uploads/2016/10/wedding-bells.jpg">
</div>
<a href="http://www.angeldesignsjewelry.com/bridebells/" class="angel-button">Bridal Bells</a>
</div>
</div>
<div class="col-sm-3 col-xs-12">
<div class="category-child-container">
<div class="category-thumb-container">
<img src="http://www.angeldesignsjewelry.com/wp-content/uploads/2016/10/twogether.jpg">
</div>
<a href="http://www.angeldesignsjewelry.com/twogether/" class="angel-button">Twogether</a>
</div>
</div>
<?php
}//function
}//if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment