I am editing a wordpress theme to add two fields to a slider plugin. I am using advanced custom fields to do this since I don't know PHP too well.
added customheader-img and big-descrip
$videobg_container .= '
<li>
<div class="slide-container container text-'.$videobg_alignment.'">
<div class="slide-content page-scroll" style="vertical-align:'.$videobg_vertical_alignment.';">
<div class="customheader-img">$image = get_field('.$custom_header_image.');</div>
'.$videobg_description.$videobg_title.$button1.'
<div class="big-descrip" <?php the_field( 'Subtext'); ?></div>
</div>
</div>
</li>'; }
The code above spits out a syntax error. If I change the single quotes to double quotes ('Subtext') to ("Subtext") it doesn't error out but the content I add to the custom field doesn't show up.
Any ideas what I can do here?
Thanks!
</div>
To get Image field using ACF
$image = get_field('image');
Use print_r($image); and see to that there are multiple dimensions of the image uploaded and you could display based on the key values of the array // each image contains a custom field called 'link'
$link = get_field('link', $image['ID']);
At last you can have the image as <?php echo $image['url']; ?>
To get the text or some other contents from ACF
$variable = get_field('field_name');
Another Important thing is that you have to use render of the variable to print the image that you have obtained Usage of print_r() will lead us to display the image as per our resolutions.
For more documentation visit: https://www.advancedcustomfields.com/resources/image/
Try this:
$videobg_container .='
<li>
<div class="slide-container container text-' . $videobg_alignment . '">
<div class="slide-content page-scroll" style="vertical-align:' . $videobg_vertical_alignment . '">
<div class="customheader-img">' . get_field('custom_header_image')['url'] .'</div>
'.$videobg_description.$videobg_title.$button1.'
<div class="big-descrip">'. get_field('Subtext'). '"></div>
</div>
</div>
</li>';
For more info how to query a image ACF field you could read in ACF docs