WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used the following code to create a list of my custom categories and custom post types:

                $custom_terms = get_terms('project_category', 'hide_empty=0');
                foreach($custom_terms as $custom_term) {
                        $args = array('post_type' => 'project',
                            'tax_query' => array(
                                    'taxonomy' => 'project_category',
                                    'field' => 'slug',
                                    'terms' => $custom_term->slug,
                    $loop = new WP_Query($args);
                    if($loop->have_posts()) {
                        echo '<a href="'.get_permalink().'">'.$custom_term->name.'</a>';            
                    while($loop->have_posts()) : $loop->the_post();
                        echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';

What I want to do is to hide the created anchors inside the list and only show them if the parent category is chosen. So I guess I should display them on the category site, and link the list items to the category site.

Can anyone give me a hint please?

share|improve this question
You want to make a sort-of accordion menu? – s_ha_dum Jun 7 '13 at 16:28
yes kind of, but i dont want it to work with js. this is the site: 61er.at/project_category/illustration – Max Jun 7 '13 at 17:01

Your Answer


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

Browse other questions tagged or ask your own question.