WordPress.org

Ready to get started?Download WordPress

Forums

Custom Field Suite
[resolved] Get Field's Type and Choices (for select) (3 posts)

  1. consumedesign
    Member
    Posted 1 year ago #

    Is there a way to get for example a particular field group by ID then get it's type and if a select their "Choices" with a API method?

    http://wordpress.org/extend/plugins/custom-field-suite/

  2. logikal16
    Member
    Plugin Author

    Posted 1 year ago #

    Yes and no.

    There's a get_input_fields API method that retrieves all field information within a given field group. It's not really intended to be directly accessed (it could change in time), but to use it:

    $choices = array();
    $group_id = YOUR_FIELD_GROUP_ID;
    $field_name = YOUR_SELECT_FIELD_NAME;
    
    $field_info = $cfs->api->get_input_fields($group_id);
    foreach ($field_info as $field) {
        if ('select' == $field->type && $field_name == $field->name) {
            $choices = $field->options['choices'];
        }
    }
    
    // Output the choices
    var_dump($choices);
  3. consumedesign
    Member
    Posted 1 year ago #

    Cool thanks I'll give it a try. BTW, LOVE the plug in... great job.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic