Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <?php
  2.  
  3. $terms = wp_get_post_terms( $post->ID, 'plan type' );
  4. if($terms){
  5. // post has course_type terms attached
  6. $course_terms = array();
  7. foreach ($terms as $term){
  8. $course_terms[] = $term->slug;
  9. }
  10.  
  11. $original_query = $wp_query;
  12. $wp_query = null;
  13. $wp_query = new WP_Query( array(
  14. 'post_type' => 'floorplans',
  15. 'tax_query' => array(
  16. array(
  17. 'taxonomy' => 'plan type',
  18. 'field' => 'slug',
  19. 'terms' => $course_terms, //the taxonomy terms I'd like to dynamically query
  20. 'posts_per_page' => '-1',
  21. ),
  22. ),
  23. 'orderby' => 'title',
  24. 'order' => 'ASC',
  25. 'posts_per_page' => '-1',
  26. ));
  27.  
  28. if ( have_posts() ): ?>
  29. <ul class="gallery_list cf">
  30. <?php
  31. while (have_posts() ) : the_post();
  32. $thumb = get_field('floorThumb');
  33. ?>
  34. <li>
  35. <a href="<?php the_permalink(); ?>">
  36. <div class="gallery_thumb">
  37. <img src="<?php echo $thumb['url']; ?>" alt="<?php echo $thumb['alt']; ?>">
  38. </div>
  39. <div class="overlay"></div>
  40. <h2><?php the_title(); ?></h2>
  41. </a>
  42. </li>
  43. <?php endwhile; ?>
  44. </ul>
  45. <?php endif;
  46. $wp_query = null;
  47. $wp_query = $original_query;
  48. wp_reset_postdata();
  49. } // end if($terms)
  50. } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement