Support

Account

Home Forums ACF PRO Duplicate Taxonomy with Reverse Relationship Reply To: Duplicate Taxonomy with Reverse Relationship

  • I think I might have been over-thinking this. I resolved this with the following:

    
    <?php
    $post_type = 'research-data';
    $tax = 'research-cats';
    $tax_terms = get_terms($tax,'hide_empty=0');
    
    //list everything
    if ($tax_terms) {
      foreach ($tax_terms  as $tax_term) {
        $args=array(
          'post_type' => $post_type,
          "$tax" => $tax_term->slug,
          '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=\"tax_term-heading\" id=\"".$tax_term->slug."\"> $tax_term->name </h2>";
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
            <?php
          endwhile;
         // echo "<p><a href=\"#top\">Back to top</a></p>";
        }
        wp_reset_query();
      }
    }
    ?>