Title: Custom Markup Variable for button group
Last modified: July 6, 2023

---

# Custom Markup Variable for button group

 *  Resolved [Kamio](https://wordpress.org/support/users/dotnetdiva/)
 * (@dotnetdiva)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/custom-markup-variable-for-button-group/)
 * I am trying to use the Custom Markup Variable feature to display a different 
   name based on what a button group value is. My sample code is below, and I’m 
   outputting the return value as {baseDescription}. My ACF Button Group choices
   are:
   BaseExpansion
 * <?php
   $isExpansion = ”;if($base_game$ == ‘Base’) $isExpansion = ”else $isExpansion
   = ‘Expansion’
 * return [
   ‘baseDescription’=> $isExpansion];

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

 *  Plugin Author [WPLake](https://wordpress.org/support/users/wplakeorg/)
 * (@wplakeorg)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/custom-markup-variable-for-button-group/#post-16877639)
 * Hi [@dotnetdiva](https://wordpress.org/support/users/dotnetdiva/)
 * Unfortunately the code you provided wouldn’t work, as it has syntax errors.
 * Please see below for a code snippet. You can use that as a base. See the “fixme”
   comment lines in the file, where you’d need to replace it with your values.
 * Kindly note that in the Database, only the value of the selected choice is stored(
   from the field settings). So, if your button group has the selected choice as‘
   base: Base’, you’ll need to compare exactly with ‘base’, but not with ‘Base’.
 *     ```wp-block-code
       <?php
   
       // fixme use your field name in the quotes instead of 'base_game'
       $baseName = $_fields['base_game'] ?? '';
   
       $baseDescription = '';
   
       switch ($baseName) {
           // fixme use your target value in the quotes
           case 'base':
               // fixme use your target label in the quotes
               $baseDescription = 'Expansion';
               break;
       }
   
       return [
           'baseDescription' => $baseDescription,
       ];
       ```
   
 *  Thread Starter [Kamio](https://wordpress.org/support/users/dotnetdiva/)
 * (@dotnetdiva)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/custom-markup-variable-for-button-group/#post-16879132)
 * Thank you so much, got it working now!

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

The topic ‘Custom Markup Variable for button group’ is closed to new replies.

 * ![](https://ps.w.org/acf-views/assets/icon-256x256.gif?rev=3022872)
 * [Advanced Views - Display Custom Fields (ACF, Pods, MetaBox), Posts, CPT and Woo Products anywhere in Gutenberg, Elementor, Divi, Beaver...](https://wordpress.org/plugins/acf-views/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/acf-views/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/acf-views/)
 * [Active Topics](https://wordpress.org/support/plugin/acf-views/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/acf-views/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/acf-views/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Kamio](https://wordpress.org/support/users/dotnetdiva/)
 * Last activity: [2 years, 11 months ago](https://wordpress.org/support/topic/custom-markup-variable-for-button-group/#post-16879132)
 * Status: resolved