I have a problem with my shortcode that I created to run in a wordpress environment.
I'm not an expert with shortcode, that's the deal:
add_shortcode('key_value' , 'key_value' );
function key_value( $atts, $content = null ) {
$atts = shortcode_atts( array(
'title' => '',
'url' => '',
), $atts );
if ($atts['title']) {
$html = '<li><strong>'.$atts['title'].': </strong>'.$content.'</li>';
} elseif ($atts['url'] && $atts['title']) {
$html = '<li><a href="'.$atts['url'].'" target="_blank">'.$atts['title'].'</a></li>';
}
return $html;
}
I want to return the second if statement because I've got a bunch of shortcode like that:
[key_value title="Delivery"]Fast[/key_value]
[key_value title="Duration"]2 weeks[/key_value]
And they work fine but the last one:
[key_value title="Info Session" url="/info/"][/key_value]
doesn't work and I don't understand why because, if I var_dump my array $atts, I'm able to see both value.
Any suggestion?