Support

Account

Home Forums General Issues Get taxonomy name from 'Taxonomy' field and insert into custom loop as category? Reply To: Get taxonomy name from 'Taxonomy' field and insert into custom loop as category?

  • Yes, that makes more sense. If I’m understanding correctly then the changes to the query that I posted should be working. Maybe it has something to do with using the global $wp_query variable, you shouldn’t be doing that.

    also, just to be sure, did you change your taxonomy here to the slug for your custom taxonomy and $term_id to the term ID that you want to return?

    
    <?php
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
      $args = array (
        'post_type'	=> 'exercise-database',
        'tax_query'  =>  array(
          array(
            'taxonomy' => 'your taxonomy here',
            'terms' => array($term_id),
            'operator' => 'IN'
          )
        ),
        'pagination' => true,
        'paged' => $paged,
        'order' => 'DESC',
      );
    
      $my_query = new WP_Query( $args );
      if ($mny_query->have_posts()) {
        while ($wp_query->have_posts()) {
          $wp_query->the_post();
          ?><h2><?php the_title(); ?></h2><?php 
        } // end while
       wp_reset_postdata();
      } // end if