Hi, I’m new to wordpress 3.5
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
foreach(get_categories() as $category)
{
$category_id= $category->cat_ID;
$field=get_field(‘select_to_display_’,$category_id); //nothing is displaying here
echo $field[‘value’]; //nothing is displaying here
if($field[‘value’] == ‘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. Please help me.