• Have this code to display $unique_thelocation(meta value) as Tags and display each post foreach tag but its not displaying well. Not sure if my code is right.

    but i need help to display each post $unique_thelocation. Thank you!

    $place = get_category(get_query_var(‘cat’))->name;
    echo ‘<div>’;
    query_posts( array ( ‘category_name’ => $place, ‘posts_per_page’ => 5 ) );
    while (have_posts()) : the_post();

    $args = array(‘location’=>” );
    $place = get_post_meta( get_the_ID(), ‘place’, true );
    $place = wp_parse_args($place, $args);
    foreach($place as $key => $value)
    {
    $thelocations[] = $place[location];
    }

    endwhile;
    $unique_thelocations = array_unique($thelocations, SORT_REGULAR);
    foreach($unique_thelocations as $unique_thelocation)
    {
    echo ‘

    • ‘ . $unique_thelocation . ‘‘ ‘;
      if (have_posts() ) :
      while (have_posts()) : the_post();
      echo ‘<p>’; the_title(); ‘</p>’;
      endwhile;
      endif;
      echo’
    • ‘;
      }
      echo ‘</div>’;

The topic ‘get post Foreach tag invalid post in loop. HELP!’ is closed to new replies.