Created
January 5, 2015 15:26
-
-
Save jackabox/702cac3cffb0fae1e743 to your computer and use it in GitHub Desktop.
Custom posts, by custom taxonomy.
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 characters
| <?php | |
| $categories = get_terms( 'service-category' ); | |
| foreach ( $categories as $category ) { | |
| $services = new WP_Query( | |
| array( | |
| 'post_type' => 'services', | |
| 'showposts' => -1, | |
| 'tax_query' => array( | |
| array( | |
| 'taxonomy' => 'service-category', | |
| 'terms' => array( $category->slug ), | |
| 'field' => 'slug' | |
| ) | |
| ) | |
| ) | |
| ); | |
| ?> | |
| <div class="service__list-box"> | |
| <h3><?php echo $category->name; ?></h3> | |
| <ul> | |
| <?php while ($services=->have_posts()) : $services=->the_post(); ?> | |
| <li><?php the_title(); ?></li> | |
| <?php endwhile; ?> | |
| </ul> | |
| </div> | |
| <?php | |
| // Reset things, for good measure | |
| $services = null; | |
| wp_reset_postdata(); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment