You need to pass $atts
as parameter to the function. Also you don’t need to use extract()
function and better you avoid this extract
function as much as you can. So your whole code block will be-
function some_function_bbb( $atts ) {
$atts = shortcode_atts(
array(
'hexabexa' => 0
),
$atts
);
ob_start();
?>
<div class="newsletter <?php echo $atts['hexabexa'] == 1 ? 'newsletter2' : '' ?>">
<h2>Plugin Works!</h2>
</div>
<?php
return ob_get_clean();
}
add_shortcode('some_function_bbb', 'some_function_bbb');
// Call it like [some_function_bbb hexabexa=1]
And lastly you are passing your shortcode attribute wrong. You declared your attribute as hexabexa
and passing the attribute as hexebexa
. The e should be a in your shortcode. So fix this typo also.
Hope that helps.