Last active
February 8, 2016 18:31
-
-
Save jdsteinbach/fe79dc83ab149efbc290 to your computer and use it in GitHub Desktop.
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 | |
| if ( ! function_exists( 'get_color_cpts' ) ) { | |
| function get_color_things( $color, $cpt ) { | |
| $this_query_args = array( | |
| 'post_type' => $cpt, | |
| 'numberposts' => -1 // or whatever # you want if you need this limited | |
| 'orderby' => 'date', | |
| 'order' => 'DESC' // if you need to change order do that here | |
| 'tax_query' => array( | |
| array( | |
| 'taxonomy' => 'colors', | |
| 'field' => 'slug', | |
| 'terms' => $color | |
| ) | |
| ) | |
| ); | |
| $this_query = new WP_Query( $this_query_args ); | |
| wp_reset_postdata(); | |
| return $this_query->posts; | |
| } | |
| } | |
| $post_types = array( 'plates', 'bowls', 'cups' ); | |
| foreach ( $post_types as $pt ) { | |
| $$pt = get_color_things( $post->post_name, $pt ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment