Hi i am trying to display posts of a custom taxonomy based on its terms.The below code returns one after other what i need is only for one particular term. For example i have two cities under my custom taxonomy city-guide-cities they are lets say paris and newyork.I need to display only posts under paris. I tried in wpq array to pass paris as term arg it display only paris posts but the loop works. means paris posts display under first paris then under newyork.I do not want newyork to display in there or not want the loop to run once paris or newyork is loaded.
<?php
$terms = get_terms('city-guide-cities');
foreach ($terms as $term) {
$wpq = array ('taxonomy'=>'city-guide-cities','term'=>$term->slug);
$myquery = new WP_Query ($wpq);
$article_count = $myquery->post_count;
echo "<h3 class=\"term-heading\" id=\"".$term->slug."\">";
echo $term->name;
echo "</h3>";
if ($article_count) {
echo "<ul>";
while ($myquery->have_posts()) : $myquery->the_post();
echo "<li><a href=\"".get_permalink()."\">".$post->post_title."</a></li>";
endwhile;
echo "</ul>";
}
}
?>