A simple wordpress shortcode function gets the querystring key => value pair from the URL and outputs the value onto the page where the shortcode is placed. I set the parameter in the shortcode to determine which key to call e.g. [urlparam param="username"].
Unfortunately, if there is no querystring or if the querystring key is not present then the raw shortcode displays on the page rather than rendering any result or displaying nothing. How would I edit the shortcode function so that nothing displays if there is no querystring or if the key being looked for is not there?
function urlparam_function( $atts ) {
extract( shortcode_atts( array(
'param' => 'param',
), $atts ) );
return $_GET[$param];
}
add_shortcode('urlparam', 'urlparam_function');