Hello!
I’m beginner with code…
I have a template create with elementor pro to display dinamic custom fields.
I need to display before the dinamic content their label, for example:
Colour: red
Now it only appears red, I would like their label before, in this case display “Colour:”
I found that code but is it what I need for?
<?php
$field = get_field_object('my_field');
?>
<p><?php echo $field['label']; ?>: <?php echo $field['value']; ?></p>
If it’s OK, where I have to place that code?
Thank you in advanced!
I have the same doubt with another code, if colour is empty, I would loke to hiding that field (this one and all I have).
With this code is possible? And where to place it?
<?php
$fields = get_field_objects();
<?php if( $fields ): ?>
<ul>
<?php foreach( $fields as $field ): ?>
<?php if( $field['value'] ): ?>
<li><?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
THANK YOU SO MUCH FOR YOUR HELP
The code you are finding would be added to the page template code and can’t be used in elementor. Adding code to elementor is not a simple process and I can’t really help you much there. You should do a search on adding code to elementor. The Code Snippets plugin is may help you. You may need to either build a shortcode or some other way. There are likely other ways to do this if you search.