Get select choices

Support General Get select choicesResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #40996
    luigi gaudinoluigi gaudino
    Participant

    Hello i created a simple select:

    • id:cars
    • choices: opel:opel - volvo:volvo
    • assigned to custom post type: services(created with metabox)

    All is working good but how can i get list of possible choices from a page in php?

    I tried print_r(rwmb_get_field_settings( 'cars' )) but seem to work only from services, not from pages.

    #41002
    PeterPeter
    Moderator

    Hello,

    You can pass the post (service) ID to the third parameter to display the field settings anywhere on. your site. For example:

    rwmb_get_field_settings( 'cars', '', 123 )

    where 123 is the service ID.

    Please read more on the documentation https://docs.metabox.io/functions/rwmb-get-field-settings/#arguments

    #41007
    luigi gaudinoluigi gaudino
    Participant

    Thanks very good, i noticed function rwmb_get_registry, can you make a example how to use it to get field 'cars' without address to services?

    #41027
    PeterPeter
    Moderator

    Hello,

    If you want to use the helper function rwmb_get_registry(), please check this example code:

    $meta_box_registry = rwmb_get_registry( 'meta_box' );
    
    $meta_box = $meta_box_registry->get( 'field-group-id' );
    
    echo "<pre>";
    print_r ( $meta_box->meta_box['fields'] ); //print out the list of fields
    echo "</pre>";

    Please read more on the documentation https://docs.metabox.io/functions/rwmb-get-registry/

    #41029
    luigi gaudinoluigi gaudino
    Participant

    ok great. Thanks and resolved!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.