Created
February 7, 2015 00:35
-
-
Save vimes1984/6edf8f0eecfa0fd1c5bf to your computer and use it in GitHub Desktop.
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
/** | |
* Retruns cat as buttons children for isotope loop | |
*/ | |
function woocommerce_get_cat_children(){ | |
if (is_product_category()) { | |
global $wp_query; | |
$cat = $wp_query->get_queried_object(); | |
$catID = $cat->term_id; | |
$taxonomy_name = "product_cat"; | |
$termchildren = get_term_children( $catID, $taxonomy_name ); | |
echo "<div ok-key='filter' opt-kind=''>"; | |
echo '<button ok-sel="*" class="button" ng-click="showall()">Show All</button>'; | |
foreach ( $termchildren as $child ) { | |
$term = get_term_by( 'id', $child, $taxonomy_name ); | |
echo '<button ok-sel=".'.$term->slug.'" class="button filtercats" ng-click="removeallother(\''.$term->slug.'\')" markable>' . $term->name . '</button>'; | |
} | |
echo "</div>"; | |
} | |
if ( is_shop() ){ | |
global $wp_query; | |
$cat = $wp_query->get_queried_object(); | |
$catID = $cat->term_id; | |
$args = array( | |
'type' => 'product', | |
'child_of' => 0, | |
'orderby' => 'name', | |
'order' => 'ASC', | |
'hide_empty' => 1, | |
'hierarchical' => 0, | |
'depth' => 1, | |
'taxonomy' => 'product_cat', | |
); | |
$categories = get_categories( $args ); | |
echo "<div ok-key='filter' opt-kind=''>"; | |
echo '<button ok-sel="*" class="button" ng-click="showall()">Show All</button>'; | |
foreach ( $categories as $child ) { | |
if($child->parent == 0){ | |
echo '<button ok-sel=".'.$child->slug.'" class="button filtercats" ng-click="removeallother(\''.$child->slug.'\')" markable>' . $child->name . '</button>'; | |
} | |
} | |
echo "</div>"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment