• Resolved cxp4

    (@cxp4)


    Hi,
    using oxygen builder which has no functions.php, I created a plugin to add fields to one cpt.
    The part for fields declaration looks like that:

    add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
    function your_prefix_register_meta_boxes( $meta_boxes ) 
    {
    bla
    bla
    bla
        return $meta_boxes;
    }

    Now I want to add fields to another cpt. Can I do it using the same plugin? What do I have to do to make it work? Change name of on one instance for
    – your_prefix_register_meta_boxes
    – $meta_boxes
    ???
    Thanks

    • This topic was modified 3 years, 4 months ago by cxp4.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Neo WhiteRabbit

    (@longnguyen89)

    Hi,

    You can add another function to register a new meta box and custom fields, like this

    add_filter( 'rwmb_meta_boxes', 'register_new_meta_boxes' );
    function register_new_meta_boxes( $meta_boxes ) {
        // do your stuff
        return $meta_boxes;
    }

    or just add more elements to the $meta_boxes array, like this

    add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
    function your_prefix_register_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = [
            ...
        ];
    
        $meta_boxes[] = [
            ...
        ];
        
        return $meta_boxes;
    }
    Thread Starter cxp4

    (@cxp4)

    Thanks a lot

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding another field group on same php file’ is closed to new replies.