How to make different custom meta for different custom taxonomies?

Support MB Term Meta How to make different custom meta for different custom taxonomies?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35970
    indatext.comindatext.com
    Participant

    Hi, I am using filter as per https://docs.metabox.io/extensions/mb-term-meta/ to display custom meta for some taxonomies.

    But I need to set different set of metas for some other taxonomies. Like I want to have different meta fields for different taxonomies.

    The example in Docs shows only case where the same set of fields can be shared across different taxonomies.

    Is variable name $meta_boxes reserved somehow? Can I use another variable to set array of fields for other taxonomy for the same filter, or I have to set up a completely different filter with other variable name for $meta_boxes array? Feeling a bit puzzled.

    #35978
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Sorry, I do not understand the question clearly. Do you mean to create different custom fields for other terms of a taxonomy? Like this topic https://support.metabox.io/topic/adding-field-group-for-woocommerce-category/

    In the documentation, you can use the same custom fields for all terms of other taxonomies.

    #35983
    indatext.comindatext.com
    Participant

    Yes, I found how to do it in UI. Its OK.
    I just do not see in docs how to do this programmatically, i.e. 2 different taxonomies, 2 different sets of meta fields - how prefix register filter will look like for rwmb_meta_boxes?

    #35987
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Here is an example:

    add_filter( 'rwmb_meta_boxes', 'prefix_register_taxonomy_meta_boxes' );
    function prefix_register_taxonomy_meta_boxes( $meta_boxes ){
        $meta_boxes[] = [
            'title'      => 'Category Fields',
            'taxonomies' => 'category', // THIS: List of taxonomies. Array or string
    
            'fields' => [
                ...
            ],
        ];
    
        $meta_boxes[] = [
            'title'      => 'Tag Fields',
            'taxonomies' => 'post_tag', // THIS: List of taxonomies. Array or string
    
            'fields' => [
                ...
            ],
        ];
        return $meta_boxes;
    }
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.