Getting Default Values from Shortcode Attributes NOT WORKING (a bug?)
-
I am trying to get default values from shortcode attribute but it is not working. Setting default value for my dropdown the usual way (e.g. default:2) works as expected but when I try to set value from shortcode (e.g. default:myattr) it is not working. My form shortcode is following
[contact-form-7 id="994" title="Test" myattr="2"]
, my for content is following[select menu-788 default:myattr "Option1" "Option2" "Option3"]
and I have following code in my functions.php:
`add_filter( ‘shortcode_atts_wpcf7’, ‘custom_shortcode_atts_wpcf7_filter’, 10, 3 );
function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) {
$my_attr = ‘myattr’;if ( isset( $atts[$my_attr] ) ) {
$out[$my_attr] = $atts[$my_attr];
}
return $out;
}`
I have tested many combinations (with/without quotes in shortcode, different order…) but no luck.
- The topic ‘Getting Default Values from Shortcode Attributes NOT WORKING (a bug?)’ is closed to new replies.