How to list custom taxonomy in columns
-
Hello,
I am trying to generate a list of custom taxonomies that displays both parent and child terms. Here is the code I have so far, it displays a list of parent terms in 3 columns the way I want it to but when I change the depth to 0 to display child terms it breaks the layout and gives me a single column list rather than 3 columns. Any hints as to what I am doing wrong would be greatly appreciated.<?php /* Template Name: Listing Page */ get_header(); ?> <div id="main"><!-- start #content --> <div id="post-area"><!-- start #blog-single --> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="breadcrumb"> <?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); ?> </div><!--breadcrumb--> <h1><?php the_title(); ?></h1> <div class="add-listing"> <?php echo do_shortcode( '[dr_add_listing_btn text="Add Listing" view="always"]' ) ?> </div><!--add-listing--> <div class="listing-search"> <?php echo do_shortcode( '[ULWPQSF id=2461]' ) ?> </div><!--listing-search--> <div id="content-area"> <?php the_content(); ?> </div><!--content-area--> <?php $catArray = explode("</li>",wp_list_categories('taxonomy=listing_state&hide_empty=0&title_li=&echo=0&depth=1&hierarchical=1&show_option_none=Nocategories')); $catCount = count($catArray) - 1; $catColumns = round($catCount / 3); $twoColumns = round($catColumns + $catColumns); for ($i=0;$i<$catCount;$i++) { if ($i<$catColumns){ $catLeft = $catLeft.''.$catArray[$i].'</li>'; } elseif ($i<$twoColumns) { $catMiddle = $catMiddle.''.$catArray[$i].'</li>'; } elseif ($i>=$catColumns){ $catRight = $catRight.''.$catArray[$i].'</li>'; } }; ?> <ul class="left"> <?php echo $catLeft; ?> </ul> <ul class="middle"> <?php echo $catMiddle; ?> </ul> <ul class="right"> <?php echo $catRight; ?> </ul> <?php endwhile; endif; ?> <?php wp_link_pages(); ?> </div><!-- post-area --> </div><!--main --> <?php get_sidebar(); ?> <?php get_footer(); ?>
- The topic ‘How to list custom taxonomy in columns’ is closed to new replies.