Querying and looping categories or posts within a complex/select field
-
Hey there,
I’m trying to retrieve categories within a field (make method).
Basically I’m trying to achieve the following:$argsCat = array( 'orderby' => 'ID', 'order' => 'ASC' ); $categories = get_categories( $argsCat ); // My field Container::make('post_meta', __( 'My field' ) ) ->show_on_post_type('page') ->add_fields( array( // gallery Field::make( 'complex', 'h_hero_slider', __( 'Ajouter un slide' ) ) ->add_fields( '', [ Field::make( 'select', 'cat', 'Catégorie slider' ) ->set_width(50) ->add_options( array( foreach ( $categories as $category ) : '$category->cat_ID' => '$category->name' endforeach; ) ) ->set_required( true ), ]), ));
But it appears that looping within the add_options part doesn’t work at all.
Do you have an idea?Thx for your precious help!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Querying and looping categories or posts within a complex/select field’ is closed to new replies.