-
-
Save Teino1978-Corp/f45fc09ffe952dd9d617 to your computer and use it in GitHub Desktop.
Conditional Logic Basic Syntax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) | |
{ | |
$meta_boxes[] = array( | |
'id' => 'brand_product', | |
'title' => 'Brands and Products', | |
'post_types' => array( 'post', 'page' ), | |
'context' => 'normal', | |
'priority' => 'high', | |
// Conditional Logic can be applied to Meta Box | |
// In this example: Show this Meta Box by default. Hide it when post format is aside | |
'hidden' => array( 'post_format', 'aside' ), | |
'fields' => array( | |
array( | |
'id' => 'brand', | |
'name' => 'Brand', | |
'desc' => 'Pick Your Favourite Brand', | |
'type' => 'select', | |
'options' => array( | |
'Apple' => 'Apple', | |
'Google' => 'Google', | |
'Microsoft' => 'Microsoft' | |
) | |
), | |
array( | |
'id' => 'apple_products', | |
'name' => 'Which Apple product that you love?', | |
'type' => 'radio', | |
'options' => array( | |
'iPhone' => 'iPhone', | |
'iPad' => 'iPad', | |
'Macbook' => 'Macbook', | |
'iWatch' => 'iWatch' | |
), | |
// Conditional Logic can applied to fields | |
// In this example: Show this field by default, | |
// hide it when user selected different value than 'Apple' on brand select field | |
'hidden' => array( 'brand', '!=', 'Apple' ) | |
) | |
) | |
); | |
return $meta_boxes; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment