Pass $cmb->object_id to function in select options
-
Hi
I’m trying to pass $cmb->object_id to a function that creates an array for the options of a select field.
$cmb->add_field( array( 'name' => __( 'Test Select ' . $cmb->object_id , 'cmb2' ), 'id' => 'select', 'type' => 'select', 'show_option_none' => true, 'options' => example_get_array($cmb->object_id), ) );
Everything works as expected with the name, and the correct ID is added.
When I pass the ID to the function, example_get_array, though it isn’t set (0).
Could anyone please advise as to what I need to do correctly to pass the ID of the current post to the function.
- The topic ‘Pass $cmb->object_id to function in select options’ is closed to new replies.