Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Luke Lee
Luke Lee
7,577 Points

Advanced Custom Field select display result twice?

I am using Advanced Custom Field in Wordpress. I followed the tutorial, use the_field('brand') to display the value of custom field. However, when I choose select field type, the result displayed twice. Like: RED:RED

I assume one is label, one is value? how can I only show the value in frontend?

2 Answers

Anthony Moore
Anthony Moore
2,282 Points

Can you share the code you are using?

Luke Lee
Luke Lee
7,577 Points

My code is:

<?php
$args = array('post_type' => 'kosher',$current_query['taxonomy'] => $taxonomy_term);
    $the_query = new WP_Query( $args );
    if ( have_posts() ) : while ( $the_query -> have_posts() ) : $the_query -> the_post(); ?>   
        <p><b><?php the_field('brand');  ?></b> &nbsp;<?php the_field('key'); ?> &nbsp;<?php the_title(); ?> &nbsp;<?php the_field( 'description' ); ?> </p>
        <?php endwhile; else: ?>
        <p>There are no posts or pages here</p>
<?php endif; }?>

Sorry, the markdown cheatsheet is really stupid. I could never get it display properly.

Luke Lee
Luke Lee
7,577 Points

Never mind I fixed it.