Last active
October 27, 2022 21:56
-
-
Save tevashov/5172380 to your computer and use it in GitHub Desktop.
Get posts from custom tax grouped by terms (WP API) #WP
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
| $myterms = get_terms('retouch_types', 'orderby=none&hide_empty'); | |
| foreach ($myterms as $term) { | |
| setup_postdata($post); | |
| $term->name; | |
| //select posts in this category, and of a specified content type | |
| $posts = get_posts( array( | |
| 'post_type' => 'retouch', | |
| 'tax_query' => array( | |
| array( | |
| 'taxonomy' => 'retouch_types', | |
| 'field' => 'slug', | |
| 'terms' => $term->slug | |
| ) | |
| ) | |
| )); | |
| // begin cycle through posts of this category | |
| foreach($posts as $post) { | |
| the_title(); | |
| the_excerpt(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment