WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] List Taxonomies with the posts from that taxonomy

[Resolved] List Taxonomies with the posts from that taxonomy

  • Hi,

    What I am trying to display is this:

    Taxonomy01 Name
    – Post Title
    – Post Title
    – Post Title

    Taxonomy02 Name
    – Post Title
    – Post Title
    – Post Title

    Does anyone have any idea how I could do this?

    Thanks, Kris

Viewing 2 replies - 1 through 2 (of 2 total)
  • Never mind, I found what I was looking for:


    http://wordpress.org/support/topic/375845?replies=3

    Just in case anyone ever comes across this thread again, I simplified the code from that other post a little to suit my needs. Here’s what I ended up with.

    <?php
      // display quick links list with hashtag
      $terms = get_terms('clips_category');
      echo "<ul>";
      foreach ($terms as $term) {
        $wpq = array ('taxonomy'=>'clips_category','term'=>$term->slug);
        $query = new WP_Query ($wpq);
        echo "<li>";
        echo "<a href=\"#".$term->slug."\">".$term->name."</a>";
        echo "</li>";
      }
      echo "</ul>";
    
      // list taxonomies
      foreach ($terms as $term) {
        $wpq = array ('taxonomy'=>'clips_category','term'=>$term->slug);
        $query = new WP_Query ($wpq);
        echo "<h2 class=\"term-heading\" id=\"".$term->slug."\">";
        echo $term->name;
        echo "</h2>";
    
        // display posts withing taxonomy
        echo "<ul>";
        $posts = $query->posts;
        foreach ($posts as $post) {
          echo "<li><a href=\"".get_permalink()."\">".$post->post_title."</a></li>";
        }
        echo "</ul>";
      }
    
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] List Taxonomies with the posts from that taxonomy’ is closed to new replies.