'PHP Snipped not rendering in iframe
I'm trying to open the user_url within an iframe on a private user page in Wordpress.
I put the following code into a snippet:
<?php echo get_the_author_meta('user_url',$userID); ?>
When I use the short code on the user page it does display the user URL, I can also use it in an hyperlink like this:
<a href="[cmruncode name='dash']">link text</a>
But when I put the short code into an Iframe the short code does not change into the URL anymore.
<iframe src="[cmruncode name='dash']" height="300" width="300" title="Iframe"></iframe>
Does anyone knows why this is not working and know a solution?
Thanks Peter
Solution 1:[1]
If you are using WordPress shortcode then you have to call shotcode using function do_shortcode.
You can try this one
<iframe src="<?php echo do_shortcode( '[cmruncode name="dash"]' ); ?>" height="300" width="300" title="Iframe"></iframe>
And I'm not sure why anchort text display right output. That's weird.
Anyway if you used do_shortcode to output your shortcode then it will work every place.
Solution 2:[2]
This only works when I put it directly into the template, in that case no snippet-shortcode is needed at all. But the content needs to be hidden when the user is logged-out.
Normally the plugin "client portal" that I use should take care of this but it has a content block that does not support PHP and also does not render the php snippet that I made.
Any suggestions?
Solution 3:[3]
The solution was to put the iframe code completely into a snippet. Like this:
<iframe src="<?php echo the_author_meta('user_url',$userID); ?>" height="2400" width="100%" title="Iframe"></iframe>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Suresh Chand |
| Solution 2 | Peter Giesbers |
| Solution 3 | Peter Giesbers |
