Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function li_build($li_fill_1, $li_fill_2,$li_choice){
- if($li_choice == 1)
- {
- echo "<li class=" . "'sidebar-list-items'" . ">" .'<a href="'. get_term_link($li_fill_1, 'product_cat') .'">'. $li_fill_2 .'</a>'. "</li>";
- }
- elseif($li_choice == 2)
- {
- echo "<li class=" . "'sidebar-list-items'" . ">". '<a href="'. get_term_link($li_fill_1, 'product_cat') .'">'. $li_fill_2 .'</a>' . "</li>";
- }
- };
- function tag_sidebar(){
- $category_profile = array(
- 'taxonomy' => 'product_cat',
- 'orderby' => 'name',
- 'show_count' => 0,
- 'pad_counts' => 0,
- 'hierarchical' => 1,
- 'title_li' => '',
- 'hide_empty' => 0
- );; //get taxonomy in an array
- $all_categories = get_categories( $category_profile ); //get all the categories taxonomy
- echo "<ul class=" . "'sidebar-parent-list'". ">";
- //loop through each category that is a parent
- if(is_array($all_categories)){
- foreach ($all_categories as $cat) {
- if($cat->category_parent == 0) {
- $tag = get_queried_object(); // get current page we're on
- $category_id = $cat->term_id;
- $sub_category_profile = $category_profile;
- $sub_category_profile['parent'] = $category_id;
- $sub_category_profile['child_of'] = 0;
- $sub_categories = get_categories( $sub_category_profile );
- //loop through each subcategory
- if(is_array($sub_categories)) {
- foreach($sub_categories as $sub_category) {
- //Display designer name with link to subcategory matching the current page we're on
- $slugmatch = strpos($sub_category->slug, "-". $tag->slug);
- if($slugmatch)
- {
- li_build($sub_category->slug,$cat->name,1);
- }
- }
- }
- }
- }
- }
- else{
- echo "Error Displaying Category List, Please Contact Webmaster";
- }
- echo "</ul>";
- }
Add Comment
Please, Sign In to add comment