Support

Account

Home Forums ACF PRO ACF Image URL not working in search results Reply To: ACF Image URL not working in search results

  • See my comments below

      
      // you don't need this, it's already done for this template
      //global $post; 
          
      $bookingstart = get_field('booking_date_start');
      $bookingend = get_field('booking_date_end');
      $travelstart = get_field('travel_date_start');
      $travelend = get_field('travel_date_end');
      $promocode = get_field('booking_promo_code');
      
      $relatedposts = get_field('applicable_resort',$post->ID);
      if( $relatedposts ) { 
        
        // change this line
        // then use $post instead of $relatedpost
        foreach( $relatedposts as $post):  
        
          setup_postdata($post);
          $resortname = get_the_title($post->ID);
          $location = get_post_meta($post->ID,'location',true);
          $logo =  get_field('logo'); 
          $demoterms = get_the_terms($post->ID, 'demographic_category');
            if ( !is_wp_error($demoterms)) {
             $demographic_category_nolinks = wp_list_pluck($demoterms, 'name'); 
             $demographic_category_list = implode(", ", $demographic_category_nolinks);
            }
        endforeach;
      }
      
      // important, reset search loop
      wp_reset_postdata();