0

I am attempting to write a shortcode that takes a URL and builds an iframe out of it. The code for the iframe is always the same except the url.

I want to pass the url to the shortcode and build the iframe, but I can't seem to remove the double quotes.

Just as a test I tried this:

    add_shortcode( 'lead1212_player', 'lead1212_player_injection' );
function lead1212_player_injection($atts) {
    $a = shortcode_atts( array( 'url' => 'https://www.example.com' ), $atts );
    $myurl = $a['url'];
    print "myurl is $myurl";
    $myurl = str_replace('"', '', $myurl);
    print "myurl is $myurl";
}

Both print statements return the same thing. The output is myurl is "http://www.example.com" my url is "http://www.example.com"

1 Answer 1

0

do a print_r to your $a variable, there you see everything that is happening

echo '<pre>';
print_r($a);
echo '</pre>';
die();

this way you can see if the url variable has double quotes, because it seems it doesnt have.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.