Metabox repeatable fields with select options

In my dashboard admin, I have two metaboxes with repeatable fields in the same page. The first metabox has only one input value $field[tag_filter]. The second metabox has a select tag to display options.

What I'm trying to do is transform the data of the first metabox into the options of the select tag of the second metabox.

So far I've succeeded to integrate a select tag with some options in the second metabox by creating a function called get_metabox_filter_options(). This is the code:

?php 
function get_metabox_filter_options() {
    $options = array (
        'Option 1' = 'option1',
        'Option 2' = 'option2',
        'Option 3' = 'option3',
        'Option 4' = 'option4',
    );
    
    return $options;
} 
?

And this is how to get the repeatable values of the first metabox:

?php
$filters = get_post_meta( $post-ID, 'filter_repeatable_fields', true );

if ( $filters ) {
   foreach ( $filters as $filter ) :
    echo $filter['tag_filter'];
    endforeach;
}
?

So what I would like to do is to convert the values of the first metabox into options as it is shown inside the code of the function get_metabox_filter_options()

Thank you.

Topic select functions php metabox options Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.