I am trying to write a query post such that it returns a list fixed list of posts from a category along with any of the one tag associated with it. For eg:
<?php $arg = array('cat' => '1','showposts' => 10,'offset' => 0); query_posts($arg); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<a class="post-link" title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php $posttags = get_the_tags(); $count=0; if ($posttags) { foreach($posttags as $tag) { $tag_link = get_tag_link($tag->term_id); $count++; if ($count == 1)
{ echo '<a class="tag-link" href="'.get_tag_link($tag->term_id).'">#'.$tag->name.'</a>'; } } } ?>
Posts in Topic A
Post_Title_1 #tag1
Post_Title_2 #tag2
Post_Title_3 #tag3
Post_Title_4 #tag2 <– I don’t wan’t this Post one as Tag2 has been displayed already.
The issue is I want only posts with unique tags to be shown…. How can i do that… Please help
So basically you need to move the code that gets the tags to the top, check against an array if it already exists. If it does, go to the next post, otherwise display the rest of the post.