Support » Fixing WordPress » Custom Post Type – show only posts from a specific taxonomy

  • Hi WordPress-Experts,

    I’ve the following problem…

    In my theme I can manage a custom post type called AUDIO.
    The registered taxonomies are Albums, DJs, Bands, Live-Acts.
    The category structure fore these taxonomies are…

    Albums (tax)
    – DJs
    – Subcategory 1
    – Subcategory 2
    – Bands
    – Subcategory 1
    – Subcategory 2
    – Live-Acts
    – Subcategory 1
    – Subcategory 2

    DJs (tax)
    – Subcategory 1
    – Subcategory 2

    Bands (tax)
    – Subcategory 1
    – Subcategory 2

    Live-Acts (tax)
    – Subcategory 1
    – Subcategory 2

    I want to show only one specific main category (e.g. DJS and it’s subcategories). I don’t know what is the right way – to do it through taxonomies or through terms!?

    For the template I’ve got the following code…

    The problem is, that I get ALL taxonomies (DJs, Dancers, etc.)
    What do I have to change?

    <?php
       global $post;
       $term = get_query_var('term');
       $tax = get_query_var('taxonomy');
       $args=array('post_type'=> 'audio', 'post_status'=> 'publish', 'orderby'=> 'menu_order', 'caller_get_posts'=>1, 'paged'=>$paged, 'posts_per_page'=>of_get_option('sc_audioitemsperpage'));
       $taxargs = array($tax=>$term);
       if($term!='' && $tax!='') { $args  = array_merge($args, $taxargs); }
    
       query_posts($args);
    
       while ( have_posts()):the_post();
           $categories = wp_get_object_terms( get_the_ID(), 'djs');
    ?>
  • The topic ‘Custom Post Type – show only posts from a specific taxonomy’ is closed to new replies.