Using MetaBox Group with MB Term_Meta and programmatically writing MB Term_Meta

Support General Using MetaBox Group with MB Term_Meta and programmatically writing MB Term_Meta

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2229
    cbergstromcbergstrom
    Participant

    I created a plugin that is pulling in data from an external API and creating custom taxonomy terms based on it. So far I have two issues:

    1. While trying to use a clonable group of metaboxes on a taxonomy term page, If I press to clone, the fields do not get Cloned (no matter if there is an entry or not).

    2. How do I use update_term_meta on a clonable group of fields?

    #2235
    Anh TranAnh Tran
    Keymaster

    Hi,

    1. Let me check the group extension with term extension again to see if I can replicate the bug.
    2. In order to add data programmatically, the data must match the format of clone group. It should be:

    array(
        array( 'field_1' => 'value 1', 'field_2' => 'value 2', ... ),
        array( 'field_1' => 'value 1', 'field_2' => 'value 2', ... ),
        ...
    )
    #2246
    cbergstromcbergstrom
    Participant

    1. I have confirmed that the group add for MB_Term_Meta does not work on a fresh WP install on a custom post type & custom taxonomy.

    2. I can't get the data using rwmb_meta. I have to use get_term_meta in which case I get the following result by running
    print_r( $variable_result_of_get_term_meta_on_group );:

    
    Array // main array object
    (
        [0] => Array //what is this for?
            (
                [0] => Array //is this the group repeater ?
                    (
                        [subscription_id] => 102412471dfjadlsf
                        [subscription_name] => Basic
                        [subscription_amount] => 10
                    )
    
            )
    
    )
    

    Because this is a group metabox type, i'm assuming the parent array of the main key=>value pairs acts as a group repeater. what does array between the main object array and the group repeater array function for?

    Please help me solve this soon. I bought your plugin in order to make repeatable fields for both custom taxonomies & custom post types

    #2249
    Anh TranAnh Tran
    Keymaster

    Using get_term_meta is correct. The helper function rwmb_meta doesn't work for term meta as it uses different API. I decided to use native WP function to get field's value.

    I think the 2nd nested array is created when you use get_term_meta with the 3rd parameter set to false (which is default). Try using this:

    $values = get_term_meta( 'term_id', 'field_id', true );

    PS: I'm working on the group extension to make it works with Term Meta extension.

    #2253
    Anh TranAnh Tran
    Keymaster

    I've just fixed the problem with the group extension. The bug is in the JS code of Meta Box and the fix is available in the development version on Github. Please try it. It will be included in the next version of Meta Box.

    Thanks.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Using MetaBox Group with MB Term_Meta and programmatically writing MB Term_Meta’ is closed to new replies.