Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a Custom Post Type of "projects", that is categorized by a Custom Taxonomy of "industry", which is heirarchical. Projects & sub-projects are assigned to the industries. For Example, the "Academic" industry contains, three sub-industries of, University, Community College, & K-12. I need to display the list of projects.

For Example:

Academic
  -University
  -Community College
  -K-12
     -- Gordon Elementery
     -- West Lake High School
          --- Gymnasium
          --- Admin Building
          --- Cafeteria
     -- Jefferson Elementary

Right now, it lists all projects including the subprojects

Basically, if the term has no "sub-terms" it links to the single.php for that term. I also need it to just list the parent term, should that term have "sub-terms" or child terms.

I've played around with get_term_children() but just can't seem to figure out how to work this out. Any suggestions would be greatly appreciated. Thanks

share|improve this question

2 Answers 2

I think you should better use the wp_list_categories function and play with the taxonomy parameter. You'll then have access to more parameters than with *get_term_children* (depth, parent, child_of, hide_empty, etc.)

share|improve this answer
    
thanks for the suggestion. I'll try that route. I'm pulling my hair out trying to figure this out. I'll let you know how it goes. thanks –  user29489 Mar 25 '13 at 19:41

Here is some basic setup for the function that MavBzh mentioned.

<?php
$args = array(
    'title_li'          => '',
    'taxonomy'          => 'industry',
    'show_option_none'  => '',
);
?>

<ul><?php wp_list_categories( $args ); ?></ul>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.