Basically I want to display the select box so admin can select the option while creating or editing a category to display the category in front page with image or not.

I use advanced custom plugin to add a select box in categories page.
I created a custom field group of display with

field label  :  Select to display  
field name :   select_to_display_  
field type :   Select  
options :   no,yes  

location rules : Taxonomy term add/edit equal to categories.

As soon as I create the custom field the values are stored in db of wp_postmeta table as

meta_key:field key value
meta_value:a:12:{s:3:"key";s:19:"field_51d53f2ed1236";s:5:"label";s:17:"Select to display";s:4:"name";s:18:"select_to_display_";s:4:"type";s:6:"select";s:12:"instructions";s:0:"";s:8:"required";s:1:"0";s:7:"choices";a:2:{s:2:"NO";s:2:"NO";s:3:"YES";s:3:"YES";}s:13:"default_value";s:0:"";s:10:"allow_null";s:1:"0";s:8:"multiple";s:1:"0";s:17:"conditional_logic";a:3:{s:6:"status";s:1:"0";s:5:"rules";a:1:{i:0;a:3:{s:5:"field";s:19:"field_51d53f2ed1236";s:8:"operator";s:2:"==";s:5:"value";s:2:"NO";}}s:8:"allorany";s:3:"all";}s:8:"order_no";i:0;} 

When I go to dashboard->post->categories I can display the select box with options but when I select any option and click on update it is updating.

but when in index.php

echo  get_field(' select_to_display_'); //nothing is displaying here

$field = get_field_object('field_51d3f9c3f5554');

if($field['choices'] == 'false') 
        echo 'A value is  set';
     } else 

    echo 'A value is not set';

I'm always getting value is not set. I don't know whether my selected values are saving db or not. I don't have any meta key or values like wp_acf in database.

But once you select the dropdown as yes in category page it is saving even after page refresh the value is yes.

I'm getting confused whether the value is saving to db or not.

  • 1
    Please link to specific plugin when asking about one, so that others don't have to guess and spend time looking it up.
    – Rarst
    Commented Jul 4, 2013 at 14:30

1 Answer 1


In this bit of code:

$field = get_field_object('field_51d3f9c3f5554');

$field['choices'] will contain an array of the available choices for that field, not the currently selected value, $field['value'] contains the currently selected value.

However, using get_field_object when all you want is the currently selected value is unnecessary.

for the correct use of get_field(), read the documentation carefully to learn what you must pass to that function, specifically the $post_id examples section. taxonomy terms are not the same as posts, you have to pass an additional argument in the form of "$taxonomy_$term_id".

EDIT- also note, in your call to get_field(' select_to_display_'), you have a space before the key name, which will fail unless the key is actually prefixed with a space, which I presume is not the case.

  • Thank you milo but i tried even iam not able to get the selected value $field=get_field('select_to_display_',$category_id); echo $field;//nothing is displaying echo $field['value'];//nothing is displaying
    – bangari
    Commented Jul 5, 2013 at 2:57
  • plaese help with this iam really stucking from 3 days for simply getting the selected values
    – bangari
    Commented Jul 5, 2013 at 3:19
  • 1
    you need to pass literally the text category_, then the ID of the category appended to the end.
    – Milo
    Commented Jul 5, 2013 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.