Support

Account

Home Forums Backend Issues (wp-admin) select always show 2 results?

Solved

select always show 2 results?

  • I have gone through all the documents, but just couldn’t get it right. below is my code, can anyone please tell me what’s wrong with my code?
    Field name is brand
    Field type is select

    $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(); ?>	
    	<?php 
    		$field = get_field_object('brand');
    		$value = get_field('brand');
    		$label = $field['choices'][ $value ];
    	?>
            <p><b><?php print_r($label); ?></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; }?>
  • I var_dump the object:

    $field = get_field_object('brand');
    var_dump($field);

    And below is what I have got, the value is herman jansen: HERMAN JANSEN, that’s what showed up on my front end every time, what code should I use to only show “HERMAN JANSEN”?

    array(17) { 
    ["key"]=> string(19) "field_533221abdb3be" 
    ["label"]=> string(5) "Brand" 
    ["name"]=> string(5) "brand" 
    ["_name"]=> string(5) "brand" 
    ["type"]=> string(6) "select" 
    ["order_no"]=> int(3) 
    ["instructions"]=> string(0) "" 
    ["required"]=> int(0) 
    ["id"]=> string(15) "acf-field-brand" 
    ["class"]=> string(6) "select" 
    ["conditional_logic"]=> array(3) { 
    	["status"]=> int(0) 
    	["rules"]=> array(1) { 
    		[0]=> array(2) { 
    			["field"]=> string(4) "null"
    			 ["operator"]=> string(2) "==" } } 
    		["allorany"]=> string(3) "all" } 
    ["choices"]=> array(4) { 
    	["BOLS"]=> string(4) "BOLS" 
    	["HERMAN JANSEN"]=> string(13) "HERMAN JANSEN" 
    	["WARNICKS"]=> string(9) "WARNICK'S" 
    	["CARLTON BLACK"]=> string(13) "CARLTON BLACK" } 
    ["default_value"]=> string(0) "" 
    ["allow_null"]=> int(0) 
    ["multiple"]=> int(0) 
    ["field_group"]=> int(140) 
    ["value"]=> string(28) "herman jansen: HERMAN JANSEN" }
  • I solved it. I went back and deleted the “brand” field, and recreated a “manufacture” field. then just copy&paste everything in there. then it works! really wield.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘select always show 2 results?’ is closed to new replies.