利用wordpress自身强大的查询功能获取当前分类下的所有文章

    <?php 
        //get current custom post_type category
        $terms = get_the_terms( $post->ID, 'yourtaxonomy name' );
    
        // get the first term
        $term = array_shift( $terms );
        //get the slug 
        $get_current_slug = $term->slug;
    ?>
    <?php
    //create a new custom query_posts
    global $wp_query;
    query_posts( array( 
                        'post_type' => 'portfolio', 
                        'showposts' => 30,
                        'tax_query' => array( 
                                               'relation' => 'AND', 
                                               array( 
                                                      'taxonomy' => 'yourtaxonomy name', 
                                                      'field' => 'slug',
                                                      'terms' => array( 
                                                                        $get_current_slug,
                                                                        
                                                                       ) 
                                                    ) 
                                            ) 
                      ) 
    );               
    ?>                     
    <?php while ( have_posts() ) : the_post(); ?>
    <a href="<?php echo get_permalink($post->ID) ?>" class="cattitle">
    <?php the_title();?>
    </a>
    <?php endwhile; wp_reset_query();  ?>