Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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, 6 months ago by Portfoli0CSG.
    #972159

    Hey 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,
    Victoria

    #972554

    Hi Victoria,

    I’ve added access information into this replies Private Content.

    Thank you.

    #973241

    Hi 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,
    Nikko

    #974056

    Unfortunately this doesn’t work either…

    #974331

    Hi 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,
    Nikko

    #974576

    Thank you so much! Works perfectly!

    #974729

    Hi Portfoli0CSG,

    Glad we could help :)

    If you need further assistance please let us know.
    Best regards,
    Victoria

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.