Има ли начин да изключите определени тагове от цикъл на свързани публикации, докато той все още намира другите тагове? Ето кода, който имам, но съм наясно, че няма такава стойност като tag_slug__not_in, но не искам да използвам идентификатори, защото са объркани, няма ли начин да изключа тагове чрез slug и като цяло това ще работи, защото аз казвам, че всички включени етикети са някакви? Всяка помощ е високо оценена!
<?php //for use in the loop, list 5 post titles related to first tag on current post
$backup = $post; // backup the current object
$tags = wp_get_post_tags($post->ID);
$tagIDs = array();
if ($tags) {
$tagcount = count($tags);
for ($i = 0; $i < $tagcount; $i++) {
$tagIDs[$i] = $tags[$i]->term_id;
}
$args=array(
'tag__in' => $tagIDs,
'tag_slug__not_in' => array('investing', 'investment', 'travel', 'shopping', 'retail', 'organisations', 'governments', 'government', 'individuals', 'entrepeneurs', 'companies', 'markets', 'finance', 'clean-tech', 'money', 'world', 'business'),
'post__not_in' => array($post->ID),
'showposts'=>5,
'caller_get_posts'=>1,
'post_type' => array('post','indepth','feature','interview')
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) { ?>
<h3>Related Articles</h3>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<ul><li><p><a href="/bg<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></p></li>
</ul>
<?php endwhile;
} else { ?>
<?php }
}
$post = $backup; // copy it back
wp_reset_query(); // to use the original query again
?>