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();
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.