php - Querying loop with custom fields, returning no results -


im trying filter loop countries products have 'relationships' to. i've written query based on custom field returning empty know there products associated country.

my code below, ideas?

<?php   if (!is_category()) { echo '<p>showing results for:<br />'; echo 'number of results: '.$wp_query->found_posts; echo 'page '. ( get_query_var('paged') ? get_query_var('paged') : 1 ) . ' of ' . $wp_query->max_num_pages . '</p>'; }   $the_query = new wp_query( $args ); $args = array( 'meta_key' => get_field('group-tour-country'), 'meta_value' => 'china' );  if ($the_query->have_posts()): while ($the_query->have_posts()) : $the_query->the_post();      if (in_category(18)){ // group tour          if (isset($countrynames)) { unset ($countrynames); }         if (isset($countrylinks)) { unset ($countrylinks); }          $countryids = get_field('group-tour-country');         if( $countryids ):             foreach( $countryids $p): // variable must called $p (important)                 setup_postdata($p);                 $countrynames[] = get_the_title( $p->id );                 $countrylinks[] = get_the_permalink( $p->id );             endforeach;         endif;     ?>          <article style="float:left;margin: 10px 0 10px 0;">              <h2 style="background: none; line-height: normal;">                 <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">                     <?php the_title(); ?>                     <?php if (strlen(get_the_title()) > 30) {                         echo '<br />';                     } ?>                     <span style="font-size: 14px; color: #666;"><?php the_field('group-tour-duration'); ?>                         days $<?php echo $leadin = (get_field('group-tour-lead-in-price') == 0 ? "n/a" : number_format(get_field('group-tour-lead-in-price'), 0, ".", ",")); ?></span>                 </a>                 <?php                 $pacefield = get_field_object('group-tour-pace');                 $pacevalue = get_field('group-tour-pace');                 $pacelabel = $pacefield['choices'][$pacevalue];                 ?>                 <a href="<?php bloginfo('url'); ?>/more-details?field=<?php the_field('group-tour-pace'); ?>" style="float:right; margin:0 2px;" class="info-overlay help" title="<?php echo $pacelabel . ' tour - click icon more details.'; ?> ">                     <img src="<?php bloginfo('template_url'); ?>/images/icons/paced-<?php echo $pacevalue; ?>-icon.png" alt="<?php echo $pacelabel; ?> icon" class="tour-pace"/>                 </a>                 <?php                 if ( get_field('group-tour-altitude') ) {                     ?>                     <a href="<?php bloginfo('url'); ?>/more-details?field=high-altitude" class="info-overlay help" style="float:right; margin:0 2px;" title="tour @ high altitude - click icon more details.">                         <img src="<?php bloginfo('template_url'); ?>/images/icons/paced-altitude-icon.png" alt="high altitude" class="tour-pace" />                     </a>                 <?php } ?>                 <?php                 if (in_category(44)) {                 ?>                 <a href="<?php bloginfo('url'); ?>/more-details?field=rhs" class="info-overlay help" style="float:right; margin:0 2px;" title="rhs garden tour - click icon more details.">                     <i class="fa fa-leaf" style="color:#ae241b;"></i>                 </a>                 <?php } ?>             </h2>              <div style="width:150px; padding-right:5px; float: left; text-align: center">                 <?php                 if ( has_post_thumbnail() ) {                 $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->id), 'mapmedium' );                 $alt = get_post_meta(get_post_thumbnail_id($post->id), '_wp_attachment_image_alt', true);                 $url = $thumb['0'];                    echo '<a title="view '.get_the_title().' " href="' .get_the_permalink(). '"><img                                 width="150"                                 alt="'. $alt .'"                                 src="'. $url .'" /></a>';                 }                 else {                     $tourimages = get_field('group-tour-gallery');                     if ($tourimages) {                         ?>                         <a title="<?php echo $tourimages[0]['alt']; ?>" href="<?php the_permalink(); ?>"><img                                 width='150'                                 alt='<?php echo $image['alt']; ?>'                                 src='<?php echo $tourimages[0]['sizes']['mapmedium']; ?>'/></a>                     <?php                     }                 }                  $mapimage = get_field('group-tour-map');                 if( !empty($mapimage) ):                 $imglarge = $mapimage['sizes'][ 'maplarge' ];                 ?>                 <a href="<?php echo $imglarge; ?>" class="map-overlay" title="<?php the_title(); ?> group tour map" style="display:block; padding: 10px 0"><i class="fa fa-map-marker" style="color:#ae241b;"></i> view map</a>                 <?php endif; ?>             </div>             <div style="width:373px; float: left;">                 <p>                     <?php                     $shortdesc = substr(get_field('group-tour-description'), 0, stripos(get_field('group-tour-description'), "."));                     echo $shortdesc . '...';                     ?>                 </p>                  <p>                     <strong>countries visited:</strong>                     <?php                     $i = 0;                     foreach ($countrynames $country) {                         if ($i == count($countrynames) - 1) {                             echo '<a href="' . $countrylinks[$i] . '" title="' . $country . ' group tours" >' . $country . '</a>';                         } else {                             echo '<a href="' . $countrylinks[$i] . '" title="' . $country . ' group tours" >' . $country . '</a>, ';                         }                         $i++;                     }                     ?>                 </p>                  <p style="text-align: right;">                     <a href="<?php the_permalink(); ?>" class="book-online">more details &raquo;</a> &nbsp;&nbsp;&nbsp;                     <a href="<?php the_permalink(); ?>#price-guide" class="book-online">dates &amp; prices &raquo;</a>                 </p>             </div>          </article>     <?php     }     ?>   <?php endwhile; ?>   <?php else: ?>      <!-- article -->     <article>         <h2><?php _e( 'sorry, nothing display.', 'wwt' ); ?></h2>     </article>     <!-- /article -->    <?php endif; ?> 


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -