More than one taxonomy/taxonomy_advanced field = last instance overrides others
Support › General › More than one taxonomy/taxonomy_advanced field = last instance overrides othersResolved
- This topic has 2 replies, 2 voices, and was last updated 4 years, 8 months ago by
Alex.
-
AuthorPosts
-
February 24, 2021 at 5:12 PM #24611
Alex
ParticipantWhen adding more than one
taxonomyortaxonomy_advancedfields to a post/page with different and unique ids, all fields simply save the value of the last one present. In the example below, whatever value is selected forcategory_feedbecomes the saved value for bothcategory_feedandcategory_feed_shortregardless of what is selected forcategory_feed_short. How do I add multiple category select fields with ability to save a different selection for each?function stories_custom_fields($meta_boxes) { $prefix = 'category_feed_short_'; $meta_boxes[] = array( 'id' => 'category_feed_short', 'title' => 'Article feed by category - Short format', 'context' => 'normal', 'priority' => 'default', 'autosave' => true, 'post_types' => array('page'), 'include' => array( 'template' => array('page-originals-single.php') ), 'fields' => array( array( 'id' => $prefix . 'headline', 'name' => 'Headline', 'desc' => 'Default: Find out more', 'type' => 'text', ), array( 'name' => 'Category', 'id' => $prefix . 'select', 'type' => 'taxonomy_advanced', 'taxonomy' => 'category', 'field_type' => 'select_advanced', 'multiple' => false ) ) ); $prefix = 'category_feed_'; $meta_boxes[] = array( 'id' => 'category_feed', 'title' => 'Article feed by category - Article format', 'context' => 'normal', 'priority' => 'default', 'autosave' => true, 'post_types' => array('page'), 'include' => array( 'template' => array('page-originals-single.php') ), 'fields' => array( array( 'id' => $prefix . 'headline', 'name' => 'Headline', 'desc' => esc_html__('Default: A deeper look'), 'type' => 'text', ), array( 'name' => 'Category', 'id' => $prefix . 'select', 'type' => 'taxonomy_advanced', 'taxonomy' => 'category', 'field_type' => 'select_advanced', 'multiple' => false ) ) ); return $meta_boxes; } add_filter('rwmb_meta_boxes', 'stories_custom_fields');February 24, 2021 at 9:25 PM #24617Long Nguyen
ModeratorHi,
I do not see any issue with your code when testing on my local site. Screen record https://share.getcloudapp.com/04uJWOGK.
You can try to use different variable $prefix to re-check it.
$prefix1 = 'category_feed_short_'; $prefix2 = 'category_feed_';February 24, 2021 at 10:13 PM #24618Alex
ParticipantOk, thanks for testing. Must be a conflict / something specific with my site. Will figure it out. Please feel free to mark as resolved.
-
AuthorPosts
- You must be logged in to reply to this topic.