I use the script below to receive related messages by tags, but noticed that if I have a bird image with a white mark and the table is also marked in white, the table will be displayed in the bird related posts section. Is there a way to get messages that correspond to at least one of the categories, so the bird and the table will not be related to each other if they do not share the same category?
I tried setting the category__in array inside $ args, but no luck!
<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'showposts'=>6,
'caller_get_posts'=>1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) {
$my_query->the_post();
?>
<?php if ( get_post_meta($post->ID, 'Image', true) ) { ?>
<a style="text-decoration: none;" href="<?php the_permalink(); ?>">
<img style="max-height: 125px; margin: 15px 10px; vertical-align: middle;" src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, "Image", $single = true); ?>&w=125&zc=1" alt="" />
</a>
<?php } ?>
<?php
}
}
}
?>
source
share