Last active
October 18, 2017 13:55
-
-
Save anythinggraphic/f2ac7ba03b34ac65c38b13f2334d2feb to your computer and use it in GitHub Desktop.
Revisions
-
anythinggraphic revised this gist
Oct 18, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <?php /* @link TBA /* Within your custom loop, get all taxonomies for a custom post type (CPT) and display each post within those taxonomies ----------------------------------------------------------------------------------------*/ $post_type = 'your_cpt_name'; -
anythinggraphic created this gist
Oct 18, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ <?php /* @link TBA /* Within your custom loop, get all taxonmies for a custom post type (CPT) and display each post within those taxonomies ----------------------------------------------------------------------------------------*/ $post_type = 'your_cpt_name'; // Get all of the taxonomies for this post type $taxonomies = get_object_taxonomies((object) array( 'post_type' => $post_type )); ?> <div class="wrap"> <?php foreach( $taxonomies as $taxonomy ) : // Gets every "category" (term) in this taxonomy to get the posts assigned to it $terms = get_terms( $taxonomy ); foreach( $terms as $term ) : $args = array( 'taxonomy' => $taxonomy, 'term' => $term->slug, 'order' => 'ASC', 'posts_per_page' => -1, ); $loop = new WP_Query($args); if ($loop->have_posts()) : ?> <div class="row"> <h4 itemprop="headline"> <?php echo $term->name; ?> </h4> <div class="one-third-wrapper"> <?php while ($loop->have_posts()) : $loop->the_post(); ?> <article <?php post_class('one-third') ?>> <a href="<?php echo get_the_permalink(); ?>"> <?php if (has_post_thumbnail()) { the_post_thumbnail(); } ?> <?php the_title(); ?> </a> </article> <?php endwhile; ?> </div> </div> <?php endif; endforeach; endforeach; ?> </div>