I was wondering if someone could help me out. I currently have a custom post type named 'claims-accordion' and a custom taxonomy named 'claims-accordion-type'. I would like to display all 'claims-type' Terms but i would like to also display all the posts that are under that term. I would like to also create a counter that gives the first term title an 'is-active' class.

Here is the code so far:

    $_terms = get_terms( array('claim-accordion-type') );

    foreach ($_terms as $term) :

        $term_slug = $term->slug;
        $_posts = new WP_Query( array(
                    'post_type'         => 'claims_accordion',
                    'posts_per_page'    => -1,
                    'tax_query' => array(
                            'taxonomy' => 'claim-accordion-type',
                            'field'    => 'slug',
                            'terms'    => $term_slug,

        if( $_posts->have_posts() ) :

            echo ''. $term->name .'';
            while ( $_posts->have_posts() ) : $_posts->the_post();


                    <h4><?php the_title(); ?></h4>
                    <p><?php get_post_meta( get_the_ID(), 'url', true ); ?></p>




also is it better to use get_posts or wp-Query? I was wondering if someone could help me out i have been trying at this for quite a while and cant seem to get it to work. I appreciate the help.

  • this is really a php question... anyway the get_post_meta is not going to echo itself, you don't close the li tag etc – Mark Kaplun Sep 19 '16 at 17:09
  • 1
    why is it not a wordpress question? – steamfunk Sep 19 '16 at 17:28
  • it is most likely broken HTML or misconfiguration of the JS library. Wordpress specific questions, which this site is about, are usually identified by being about the use of core API, and it seems like this is not the problem in this case – Mark Kaplun Sep 19 '16 at 17:57
  • 1
    there are no misconfigurations with the js library i have checked and created a static html template with an accordion and everything is working great. this is a wordpress questions becuase it involved core wordpress functions. – steamfunk Sep 19 '16 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.