Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. add_filter( 'woocommerce_related_products_args', 'rare_related_products_by_custom_taxonomy');
  2. function rare_related_products_by_custom_taxonomy( $args ) {
  3.  
  4. global $post;
  5.  
  6. $tags = wp_get_post_terms( $post->ID, "custom_taxonomy" );
  7. foreach ( $tags as $tag ) {
  8. $tags_array[] .= $tag->term_id;
  9. }
  10.  
  11. unset( $args['post__in'] );
  12. $args['tax_query'] = array(
  13. array(
  14. 'taxonomy' => 'custom_taxonomy',
  15. 'field' => 'id',
  16. 'terms' => $tags_array,
  17. ),
  18. );
  19. return $args;
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement