Thank you it’s working now, not sure why but I copy/pasted your code first attempt, 2nd attempt manually typed it!.
Is there anyway to make it conditional so it only displays the button if it has a field value?
Hmmm, unfortunately that didn’t work either. Is there some other way I could create a button using an ACF Shortcocde instead of inserting the field in pre-existing HTML?
Any help would be much appreciated.
Thanks but I wanted the label wrapping in HTML not the value, also because you didn’t put your code in code tags when copying/pasting the quotes/apostrophes will be the wrong format.
I found this code which seems to work well:
<?php $field_name = "distance";
$field = get_field_object($field_name);?>
<?php if ($field['value']): ?>
<span class='post-meta-key'><?php echo $field['label']; ?>:</span> <?php echo $field['value']; ?>
<?php endif; ?>
Let me know if this is a good/bad solution.
I’ve now got it working with the following code:
<?php
$terms = get_the_terms( get_the_ID(), 'product_brands' );
if( ! empty( $terms ) ) : ?>
<ul>
<?php foreach( $terms as $term ) : ?>
<li class="<?php echo $term->slug; ?>">
<img src="<?php the_field('brand_logo', $term); ?>" />
</li>
<?php endforeach; ?>
</ul>
<?php
endif;
?>
I had to change the taxonomy name from brands to product_brands because I was already using a brands taxonomy for another CPT. However, this wasn’t the cause of the images not displaying, the only thing that was missing before was wrapping the <?php the_field(‘brand_logo’, $term); ?> in an image tag, seems obvious now.
Are there any issues doing it this way?.
I’ve tried all 3 return value settings. Each time, on the front-end it just displays either an array of all the image data, image id or URL.
Thanks for your input. I did look at other import plugins such as: https://en-gb.wordpress.org/plugins/wp-ultimate-csv-importer/
But most of them seem to only import to standard wordpress custom fields and not ACF specific ones unless upgrading to the PRO version.
Perhaps there is another free one someone could recommend?
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.