Support

Account

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

  • Thanks John, I appreciate your continued help.

    I’m actually not modifying the Loop per se, it’s a search result page so the ‘loop’ is standard, and on the template it starts out with the usual (if(have_posts()) : while (have_posts()) : the_post();)

    Then below that I have the code that sets up all the custom field metadata, some from the current post and some from the ‘related’ (via a relationship field) post – this code is:

    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 ) { 
      foreach( $relatedposts as $relatedpost):  setup_postdata($relatedpost);
        $resortname = get_the_title($relatedpost->ID);
        $location = get_post_meta($relatedpost->ID,'location',true);
        $logo =  get_field('logo'); 
        $demoterms = get_the_terms($relatedpost->ID, 'demographic_category');
          if ( !is_wp_error($demoterms)) {
           $demographic_category_nolinks = wp_list_pluck($demoterms, 'name'); 
           $demographic_category_list = implode(", ", $demographic_category_nolinks);
          }
      endforeach;
      }

    The reasoning behind all this is that we have two CPTs – “Deals” (‘deal’) and “Resorts” (‘resort’)……we started out with just Deals, but it quickly became apparent it was too cumbersome to keep entering what it resort-specific information into each deal, so we created the second CPT for Resorts to hold all that information that is specific to the resort, then we relate the Deal to the Resort.

    It’s all worked great everywhere except for on the search results pages, and only on this one field – the logo – that I can’t seem to get the URL for it to echo into the image tag so it can display – it works fine on other pages, just not on the search results page.

    What seems odd to me is that when I look at my wp_postmeta table in phpMyAdmin, I see the metakey (‘logo’) but there is no value….however in it’s corresponding _metakey (‘_logo’) there is a value but it’s not a URL, so I’m not sure how to use it – it is the word field followed by a number.