Home › Forums › General Issues › Values vs. Labels › Reply To: Values vs. Labels
Doesn’t work. Still returning the label.
Here is what my code looks like:
$the_query = new WP_Query( $args ); ?>
<ul>
<?php if( $the_query->have_posts() ): ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php
$value = get_field('industry_subsector');
?>
<li id="<?php echo $value; ?>">
<?php the_field('industry_subsector'); ?>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
Here is what I get…
<ul>
<li id="Building Products">Building Products</li>
<li id="General Industrial">General Industrial</li>
<li id="Specialty Chemicals">Specialty Chemicals</li>
<li id="Measurement & Controls">Measurement & Controls</li>
<li id="Automotive">Automotive</li>
</ul>
My field choices look like this:
automotive : Automotive
building_products : Building Products
measurement_controls : Measurement & Controls
paper_packaging : Paper/Packaging
general_industrial : General Industrial
specialty_chemicals : Specialty Chemicals
I want it to look like this:
<ul>
<li id="building_products">Building Products</li>
<li id="general_industrial">General Industrial</li>
<li id="specialty_chemicals">Specialty Chemicals</li>
<li id="measurement_controls">Measurement & Controls</li>
<li id="automotive">Automotive</li>
</ul>
What am I doing wrong?
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.