Have you tried wp_get_post_terms()
Example usage:
$term_lists = wp_get_post_terms($post_id, ‘product_tag’, array(“fields” => “names”));
I modified your code and got this to work on my site:
<ul id="relatedlist">
<?php
$tags = wp_get_post_terms($post_id, 'product_tag');
if ( $tags ) {
$tag_ids = array();
foreach ( $tags as $individual_tag ) array_push($tag_ids,$individual_tag->term_id);
$args = array(
'post_type' => 'product',
'tax_query' => array(
array( 'taxonomy' => 'product_tag',
'field' => 'id',
'terms' => $tag_ids
)
),
'post__not_in' => array( $post_id ),
'posts_per_page' => 8, // Number of related posts that will be shown.
);
$my_query = new WP_Query( $args );
if ( $my_query->have_posts() ) {
while ( $my_query->have_posts() ) {
$my_query->the_post(); ?>
<li>
<div class="relatedthumb">
x
<a href="https://wordpress.stackexchange.com/questions/196311/<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>">
<?php the_post_thumbnail('small'); ?>
</a>
</div>
</li>
<? }
}
}
wp_reset_query(); ?>
</ul>
note: caller_get_posts is deprecated since version 3.1