In my project, I have created a custom template where I showcase my previous projects. At the top of this template, there is a feature list where I state the features used within the project.
I have made each element editable using ACF but I know that the number of features used in each project will vary. I don’t want items in the list to be visible if they are not used. I went to the ACF documentation and found this for a basic implementation:
<?php if( get_field('field_name') ): ?>
<p>My field value: <?php the_field('field_name'); ?></p>
<?php endif; ?>
And this for a loop:
<?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; ?>
My feature list structure looks like this:
<ul>
<li><span>strategy</span>
<li><span>strategy</span>
<li><span>strategy</span>
</ul>
Firstly, which of these is the correct one for my use case? And secondly, while conventionally, you would add this to the function.php file, what is the Pinegrow way to implement?