Advanced taxonomy field does not show stored values
I'm trying to create a cloneable taxonomy_advanced field to store WooCommerce product categories, but when I set clone to true, the stored values do not show up in the edit post page, but they are actually being stored.
My configuration looks like this;
$meta_boxes[] = array(
'id' => 'wg_meta_box',
'title' => esc_html__( 'Extra options', 'wg' ),
'post_types' => array( 'page' ),
'context' => 'advanced',
'priority' => 'high',
'autosave' => true,
'fields' => array(
array(
'id' => $prefix . 'highlight_product_cat',
'type' => 'taxonomy_advanced',
'name' => esc_html__( 'Product categories', 'wg' ),
'desc' => esc_html__( 'Select product categories', 'wg' ),
'taxonomy' => 'product_cat',
'field_type' => 'select',
'clone' => true
),
),
);
When I save the page, the field in the metabox resets (showing no selected categories). However, the values are being saved. From the database;
meta_key | meta_value
-------------------------+---------------------------------------
wg_highlight_product_cat | a:2:{i:0;s:2:"16";i:1;s:2:"15";}
Now, when I set the clone option to false, I can correctly store a product category. Furthermore; when I set the type to taxonomy (instead of taxonomy_advanced), I can't clone the field.
Is this a known issue, or am I doing something wrong?
Im having this similar issue with taxonomy_advanced and select_tree. Seems like the data is being saved however when viewing the meta box after save the lower level tree values are not being displayed. I checked this issue and it seems like data is being saved as a:1:{i:0;s:7:"82,,431";}
Can you check the most recent commit on GitHub?
Hi @funkedgeek i spoke to metabox support and they came up with this fix (https://github.com/rilwis/meta-box/commit/478fed2fff7ba4396e57f328598e338013fe142f) so a slightly older commit, however it worked in my case. Im not sure if the original poster has the same issue as mine.
Both the fix and the latest version from github (master branch) fix the problem partially; when using select_advanced or select, only the first taxonomy I choose is being displayed, although all are stored and retrievable on the frontend. But when I use select_tree, they're all shown.