WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] List Taxonomies with the posts from that taxonomy (3 posts)

  1. Kris_0_o
    Member
    Posted 3 years ago #

    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

  2. Kris_0_o
    Member
    Posted 3 years ago #

    Never mind, I found what I was looking for:


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

  3. Kris_0_o
    Member
    Posted 3 years ago #

    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>";
      }
    
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic