Custom Fields
Re-Envisioned
Support MB Term Meta Please update docs

  • Creator
    Topic
  • #20229
    badabingbreda
    Participant

    Please make a small update to the docs for MB Term Meta.

    I’m adding custom fields to taxonomies that get added programatically and I noticed that my metaboxes were appearing all over the place, some multiple times. it took a while to figure out why, because only part was showing up multiple times. (this was because the fieldnames are all the same, so those get added only once, but the metabox title was showing up 6 or 7 times)

    It turned out that I had copied the demo code without noticing that the id of the meta-box was missing.

    Please accept my suggestion to add it so that others don’t make the same mistake;

    add_filter( 'rwmb_meta_boxes', 'prefix_register_taxonomy_meta_boxes' );
    function prefix_register_taxonomy_meta_boxes( $meta_boxes ){
        $meta_boxes[] = array(
            'title'      => 'Standard Fields',
            'taxonomies' => 'category', // List of taxonomies. Array or string
            'id' => "unique_id_goes_here",  // <-- Please add this
            'fields' => array(
                array(
                    'name' => 'Featured?',
                    'id'   => 'featured',
                    'type' => 'checkbox',
                ),
                array(
                    'name' => 'Featured Content',
                    'id'   => 'featured_content',
                    'type' => 'wysiwyg',
                ),
                array(
                    'name' => 'Featured Image',
                    'id'   => 'image_advanced',
                    'type' => 'image_advanced',
                ),
                array(
                    'name' => 'Color',
                    'id'   => 'color',
                    'type' => 'color',
                ),
            ),
        );
        return $meta_boxes;
    }
Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #20240
    Long Nguyen
    Moderator

    Hi,

    Thanks for pointing this out.

    If a user adds one meta box, the sample code shows the meta box title once, see my screen record https://www.loom.com/share/fe87cfec61394a1b921e3a9e2763cb36. If he adds more meta box without the meta box ID, the meta box title will display multiple times on each meta box as you said.

    I’m going to update the ID to the docs to avoid this case.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.