Title: Get Labels of Options
Last modified: September 20, 2020

---

# Get Labels of Options

 *  [masoud_wp](https://wordpress.org/support/users/masoud_wp/)
 * (@masoud_wp)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/get-2/)
 * Hi Roland
    i have multiselect checkbox in my custom template page. how to get
   labels (or “value titles”) of options?
 * for example:
    New Mexico::NM, California::CA, Maine::ME, Arizona::AZ
 * how to get “New Mexico” or “Arizona”?
    (get those that have been checked)
 * thank you in advance
    -  This topic was modified 5 years, 8 months ago by [masoud_wp](https://wordpress.org/support/users/masoud_wp/).
    -  This topic was modified 5 years, 8 months ago by [masoud_wp](https://wordpress.org/support/users/masoud_wp/).
    -  This topic was modified 5 years, 8 months ago by [masoud_wp](https://wordpress.org/support/users/masoud_wp/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Roland Barker](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/get-2/#post-13435196)
 * If you are in a shortcode template, you can use the template helper class. To
   print the value title, use the print_value method. For example:
 *     ```
       <?php $record = new PDb_Template($this); ?>
       <p>The value is: <?php $record->print_value('fieldname'); ?>.<?p>
       ```
   
 *  Thread Starter [masoud_wp](https://wordpress.org/support/users/masoud_wp/)
 * (@masoud_wp)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/get-2/#post-13435391)
 * yes but i want the label of it, not value
 * Consider the following example (in multiselect checkbox)
    Western States::optgroup,
   New Mexico::NM, California::CA, Maine::ME, Arizona::AZ
 * In your code:
    <p>The value is: <?php $record->print_value(‘fieldname’); ?>.<?
   p> output is The value is: CA
 * but i want (output):
    The label is: California
 * also i want optgroup label
    for example (output): The group is : Western States
 *  Plugin Author [Roland Barker](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/get-2/#post-13435664)
 * It does work, I just tested it, so there may be something in the field options
   configuration that is leading to a different result than you expect. Also, check
   the record values in the database directly (using phpMyAdmin) so you know exactly
   what that record value is trying to index.
 * To get the title of the optgroup that your value is in is more difficult, you’ll
   need a bit of code for that. Take a look at this gist for an idea how to do that.
 * [https://gist.github.com/xnau/a1acbd83071341989cd3f8e0d1cbd2f9](https://gist.github.com/xnau/a1acbd83071341989cd3f8e0d1cbd2f9)
 * Note that this won’t work with a multi-select type field, you’ll have to modify
   the code to deal with the fact that the saved value will be an array of values.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Get Labels of Options’ is closed to new replies.

 * ![](https://ps.w.org/participants-database/assets/icon-256x256.jpg?rev=1389807)
 * [Participants Database](https://wordpress.org/plugins/participants-database/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/participants-database/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/participants-database/)
 * [Active Topics](https://wordpress.org/support/plugin/participants-database/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/participants-database/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/participants-database/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Roland Barker](https://wordpress.org/support/users/xnau/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/get-2/#post-13435664)
 * Status: not resolved