Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Basically I need to get all posts from a particular category (or multiple categories), and list them out according to their tag. In Category X, there are the following tags, and under each tag is the link to all the posts with that tag. I have it MOSTLY working - except this is pulling ALL tags from ALL categories. Any way I can limit this output to just a particular category?

<?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="tag">' . $term->name . '</h2><ul class="post">';
          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().
    ?>
share|improve this question
1  
I figured this out. I ended up using custom posts & custom taxonomies to achieve this. I created a conditional that checks the page and lists the desired output for each page. Works like a charm. pastebin.com/cSqQtNrx –  jamie Sep 11 '12 at 23:52
    
thanks for posting an answer, really helped me out a lot :) –  Andres Ilich Nov 20 '12 at 21:17
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.