Forum Replies Created
-
AuthorPosts
-
Alex
ParticipantThank you Long. That should work.
Alex
ParticipantI have front-end React app. I am using WordPress as headless CMS. The post doesn't exists yet. Hence I do not have post_id to pass it to the function. The idea is when a user opens form to create a new post, one of the fields is the Country select field. I was hoping to get options for this front-end field by fetching options from the custom Country back-end field. It is not a direct access. My app fires REST request to the custom endpoint. The custom endpoint function uses rwmb_get_field_seetings to get options and send it back to the from-end app. Is it even possible with Metabox? It did work with ACF.
Thanks.
Alex
ParticipantHi Long,
Yes, I did use $field_id. It seems none of the helper functions work. I tried a few other with no success. The fields are visible in the Post. I can change the values.Here is just part of the Metabox.
function.php
add_filter( 'rwmb_meta_boxes', 'prefix_register_meta_boxes'); function prefix_register_meta_boxes($meta_boxes) { if (!class_exists('RW_Meta_Box')) { return; } /*================================================= * Properties Custom Type Metabox ===================================================*/ $meta_boxes[] = array( 'id' => 'property-meta-box', 'title' => esc_html__( 'Property', 'textdomain' ), 'pages' => array('property'), 'tabs' => array( 'property_location' => array( 'label' => esc_html__('Location', 'textdomain'), 'icon' => 'dashicons-location', ), ), 'tab_style' => 'left', 'fields' => array( array ( 'id' => 'country', 'name' => esc_html__( 'Country', 'textdomain' ), 'type' => 'select', 'placeholder' => esc_html__( 'Select an Item', 'textdomain' ), 'options' => array( 1 => esc_html__( 'Canada', 'textdomain' ), 2 => esc_html__( 'United States', 'textdomain' ), ), 'tab' => 'property_location', 'columns' => 12, ), ), ); return $meta_boxes; } $field = rwmb_get_field_settings('country'); -
AuthorPosts