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?

  • Do your have the field set to save and load terms?

    the taxonomy query added to your arguments should look something like this: see https://codex.wordpress.org/Class_Reference/WP_Query

    
    $args = array (
        'post_type'	=> 'exercise-database',
        'tax_query'  =>  array(
          array(
            'taxonomy' => 'your taxonomy here',
            'terms' => array($term_id), // <= this needs to be an array of term id, can have a single value
            'operator' => 'IN'
          )
        ),
        'pagination'	=> true,
    	'paged'         => $paged,
    	'order'		=> 'DESC',
    );
    

    But before you go to the trouble of creating a custom page template for every category you should think about using the template hierarchy built into WP. If you have a custom post type and you add a custom taxonomy for the CPT then you only need to create 3 template files: archive-{$custom-post-type}.php, single-{$custom-post-type}.php and taxonomy-{$custom-taxonomy}.php. It would be a lot easier than building and doing custom queries for every category.