Hello - hope this is the right place to come.
I'm trying to write a shortcode for Wordpress that compares two values, and if they match, generates content. If they don't match, no content is shown.
I'm a proper noob at this, and have tried a few ways, but no success.
The following generates the content, but it's not working.
function compare_func($atts,$content=""){
extract(shortcode_atts(array(
'val1' =>'', 'val2' => '')
, $atts));
if($val1 == $val2)
$content = '';
return $content;
}
add_shortcode('compare', 'compare_func');
[compare val1="no" val2="yes"]this is my content[/compare] outputs the conten, whereas only [compare val1="yes" val2="yes"]this is my content[/compare] should output the content. What am I doing wrong? Do I need an else clause (which I'm not sure how to add).
Any help much appreciated… I've got to learn!