• I am using this code to display all posts by tag:

    <?php query_posts('cat=20'); ?>
    
                    <?php
    //get all terms (e.g. categories or post tags), then display all posts in each term
    $taxonomy = 'post_tag';//  e.g. post_tag, category
    $param_type = 'tag__in'; //  e.g. tag__in, category__in
    $term_args=array(
      'orderby' => 'name',
      'order' => 'ASC'
    );
    $terms = get_terms($taxonomy,$term_args);
    if ($terms) {
      foreach( $terms as $term ) {
        $args=array(
          "$param_type" => array($term->term_id),
          'post_type' => 'post',
          'post_status' => 'publish',
          'posts_per_page' => -1,
          'caller_get_posts'=> 1
          );
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo '<h2 class="venue-city">' . $term->name . '</h2><ul class="venue-listing">';
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
           <?php
          endwhile;
    	  echo '</ul>';
        }
      }
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    it works beautifully except is pulling from all my categories instead of just one specific category. I need to limit this to a certain category on one page then to a certain subcategory within that category on another page. can someone help?

  • The topic ‘displaying posts by tag from a specific subcategory’ is closed to new replies.