Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have categories as cities like london or new york I also have a custom field called Location where I usually put the name of a restaurant.

I am trying to show on a separate post/page all the restaurants in a certain town. Each post I make is basically a review of a restaurant but sometimes there is a review for the food or another one for their bar.

I can t seem to figure out how to list all the restaurants in one city without getting duplicates. I have this for example:

<?php query_posts('posts_per_page=20&category_name=New York&meta_key=Location&order=DES'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php $links = get_post_custom_values("Location");
if ($links[0]!="") {
$mykey_values = get_post_custom_values('Location');
foreach ( $mykey_values as $key => $value )
{
echo $value;
echo "<br><br>";
}
}
?>

So this lists all the posts from New York and the content of the custom field called Locations. But I am getting duplicates. I would like that if there is a location on a post called Trump Tower that it will show listed only once? Any help is appreciated

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.