Advertisement
Guest User

Untitled

a guest
Nov 18th, 2011
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2. $terms = wp_get_object_terms($post->ID, 'product-vendor', array('orderby' => 'name', 'order' => 'ASC'));
  3. if(is_array($terms)) :
  4. if(isset($terms[0])) : ?>
  5. <h2>Other <?php echo $terms[0]->name; ?> Products</h2>
  6. <ul><?php
  7. $args = array(
  8. 'post_type' => 'products',
  9. 'posts_per_page'=> 5,
  10. 'tax_query' => array(
  11. array(
  12. 'taxonomy' => 'product-vendor',
  13. 'field' => 'slug',
  14. 'terms' => $terms[0]->name
  15. )));
  16. $related_posts = get_posts( $args );
  17.  
  18. if($related_posts) : ?>
  19. <ul>
  20. <?php foreach($related_posts as $related_post) : ?>
  21. <li><a href="<?php echo get_permalink($related_post->ID); ?>"><?php echo $related_post->post_title; ?></a></li>
  22. <?php endforeach; ?>
  23. </ul>
  24. <a class="button" href="<?php echo get_term_link($terms[0]); ?>">View More <?php echo $terms[0]->name; ?> Products</a>
  25. <?php else: ?>
  26. <li>No other products.</li>
  27. <?php endif; ?>
  28. <?php endif; ?>
  29. <?php endif; ?>
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement