Skip to main content

I have created a custom post type. Within that I have assigned two custom taxonomies. One (computer) is what I use to drive the template files and slug of page (taxonomy-computer.php). The second (faq-option) is what will categorize all posts associated under the first taxonomy (computer).

My issue that I am having is creating some sort of loop to list out the faq-option tax with the associated posts to that.

iei.e.

taxonomy-computer.php (computer)
-> faq-option
-> post
-> post

Currently it is listing out each term with the associated post

iei.e.

-> faq-option
-> post

-> faq-option
-> post

My main objective is to group the under the respective taxonomy. I also was trying to stay with the main loop rathrrather than create a new query. Now I am open to suggestions here.

    $terms = get_the_terms( $post->ID , 'faq-option' );

  foreach( $terms as $term ) :

        foreach( $terms as $term ) : setup_postdata($term);

      echo '<h3>'.$term->name. '</h3>' ;
        echo '<p><a href="#">'.the_title().'</a></p>';

    endforeach;
        wp_reset_postdata();
        
  endforeach;

The block of code is being added to the taxonomy-computer.php file. I also am also using pre_get_posts to change the amount of ppp as well as the order/orderby.

I am stump and open to suggestions.

Thank you!

I have created a custom post type. Within that I have assigned two custom taxonomies. One (computer) is what I use to drive the template files and slug of page (taxonomy-computer.php). The second (faq-option) is what will categorize all posts associated under the first taxonomy (computer).

My issue that I am having is creating some sort of loop to list out the faq-option tax with the associated posts to that.

ie.

taxonomy-computer.php (computer)
-> faq-option
-> post
-> post

Currently it is listing out each term with the associated post

ie.

-> faq-option
-> post

-> faq-option
-> post

My main objective is to group the under the respective taxonomy. I also was trying to stay with the main loop rathr than create a new query. Now I am open to suggestions here.

    $terms = get_the_terms( $post->ID , 'faq-option' );

  foreach( $terms as $term ) :

        foreach( $terms as $term ) : setup_postdata($term);

      echo '<h3>'.$term->name. '</h3>' ;
        echo '<p><a href="#">'.the_title().'</a></p>';

    endforeach;
        wp_reset_postdata();
        
  endforeach;

The block of code is being added to the taxonomy-computer.php file. I also am using pre_get_posts to change the amount of ppp as well as the order/orderby.

I am stump and open to suggestions.

Thank you!

I have created a custom post type. Within that I have assigned two custom taxonomies. One (computer) is what I use to drive the template files and slug of page (taxonomy-computer.php). The second (faq-option) is what will categorize all posts associated under the first taxonomy (computer).

My issue that I am having is creating some sort of loop to list out the faq-option tax with the associated posts to that.

i.e.

taxonomy-computer.php (computer)
-> faq-option
-> post
-> post

Currently it is listing out each term with the associated post

i.e.

-> faq-option
-> post

-> faq-option
-> post

My main objective is to group the under the respective taxonomy. I also was trying to stay with the main loop rather than create a new query. Now I am open to suggestions here.

    $terms = get_the_terms( $post->ID , 'faq-option' );

  foreach( $terms as $term ) :

        foreach( $terms as $term ) : setup_postdata($term);

      echo '<h3>'.$term->name. '</h3>' ;
        echo '<p><a href="#">'.the_title().'</a></p>';

    endforeach;
        wp_reset_postdata();
        
  endforeach;

The block of code is being added to the taxonomy-computer.php file. I am also using pre_get_posts to change the amount of ppp as well as the order/orderby.

I am stump and open to suggestions.

Thank you!

Source Link

List all posts associated under custom taxonomy

I have created a custom post type. Within that I have assigned two custom taxonomies. One (computer) is what I use to drive the template files and slug of page (taxonomy-computer.php). The second (faq-option) is what will categorize all posts associated under the first taxonomy (computer).

My issue that I am having is creating some sort of loop to list out the faq-option tax with the associated posts to that.

ie.

taxonomy-computer.php (computer)
-> faq-option
-> post
-> post

Currently it is listing out each term with the associated post

ie.

-> faq-option
-> post

-> faq-option
-> post

My main objective is to group the under the respective taxonomy. I also was trying to stay with the main loop rathr than create a new query. Now I am open to suggestions here.

    $terms = get_the_terms( $post->ID , 'faq-option' );

  foreach( $terms as $term ) :

        foreach( $terms as $term ) : setup_postdata($term);

      echo '<h3>'.$term->name. '</h3>' ;
        echo '<p><a href="#">'.the_title().'</a></p>';

    endforeach;
        wp_reset_postdata();
        
  endforeach;

The block of code is being added to the taxonomy-computer.php file. I also am using pre_get_posts to change the amount of ppp as well as the order/orderby.

I am stump and open to suggestions.

Thank you!