
Tagged: acf, caption, custom fields, Masonry Gallery
-
AuthorPosts
-
June 12, 2018 at 9:01 am #971573
I would like to alter my caption on my masonry grid to be custom field information (ACF) as it is a real estate website. The information only ever comes out as blank or depending how I code it, ‘Array’ etc. I have tried to link it using codes such as:
$beds = the_field(‘bedrooms’);
$bath = the_field(‘bathrooms’);
$car = the_field(‘car_spaces’);
$rent = the_field(‘rent’);$items .= “<h3 class=’av-masonry-entry-title entry-title’> {$beds}, {$bath}, {$car} | {$rent}</h3>”;
}You will find the gallery at http://www.elevateresidential.com.au/
Ps. Right now I have them set as the text ie. 2 Beds, 1 Bath, 1 Car | $350 because my client is looking at it…
-
This topic was modified 6 years, 9 months ago by
Portfoli0CSG.
June 13, 2018 at 9:53 am #972159Hey Portfoli0CSG,
Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?
Best regards,
VictoriaJune 14, 2018 at 12:48 am #972554Hi Victoria,
I’ve added access information into this replies Private Content.
Thank you.
June 15, 2018 at 11:21 am #973241Hi Portfoli0CSG,
Thanks for giving us admin and ftp access, can you try to replace this code:
$beds = the_field(‘bedrooms’); $bath = the_field(‘bathrooms’); $car = the_field(‘car_spaces’); $rent = the_field(‘rent’);
to:
$beds = get_field('bedrooms'); $bath = get_field('bathrooms'); $car = get_field('car_spaces'); $rent = get_field('rent');
Let us know if this helps.
Best regards,
NikkoJune 18, 2018 at 1:07 am #974056Unfortunately this doesn’t work either…
June 18, 2018 at 4:02 pm #974331Hi Portfoli0CSG,
It didn’t work because the code is wrong, I have replaced this code:
$beds = get_field('bedrooms'); if($beds) { echo '<ul class="test123">'; foreach($beds as $beds) { echo '<li>' . $beds . '</li>'; } echo '</ul>'; }
to:
$beds = get_field('bedrooms', $entry['ID']); if( (int)$beds > 1 ) { $beds = $beds . ' BEDS'; } else { $beds = $beds . ' BED'; }
and it works fine.
This is already outside the scope of our support but I hope this helps, also you can check on ACFs documentation on how it works.
Also just a tip, instead of using text for bedrooms or other fields that uses numbers, you can use the Number field type.
Hope it helps.Best regards,
NikkoJune 19, 2018 at 2:32 am #974576Thank you so much! Works perfectly!
June 19, 2018 at 12:03 pm #974729Hi Portfoli0CSG,
Glad we could help :)
If you need further assistance please let us know.
Best regards,
Victoria -
This topic was modified 6 years, 9 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.