Wordpress- <iframe> is incorrectly interpreting url page content - php

I'm trying to embed a vimeo player in my Wordpress 3.8 site. To make changing the video a little easier, I've created Page which just contains the url for a Vimeo video. On the site, I try to embed the video like so:
<iframe allowfullscreen="" frameborder="0" mozallowfullscreen="" src="<? echo apply_filters('the_content', get_page(925)->post_content); ?>" webkitallowfullscreen=""></iframe>
But when I view the site, it just loads an empty page template inside the frame! When I echo that php chunk outside the iframe, however, it returns the url as expected. Putting in the url directly causes it to work fine, and I've tried a ton of quotation configurations to make sure the error wasn't there. Any idea what is causing it to wig out?

why are you running apply_filters on this? Also, get_page is deprecated.
Try something like this:
<?php
$vidPost = get_post(925);
echo '<iframe allowfullscreen="" frameborder="0" mozallowfullscreen="" src="'.$vidPost->post_content.'" webkitallowfullscreen=""></iframe>';
?>

Related

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:
link text
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
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.
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?
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>

How to get the iframe url for specific domain in WordPress

My WordPress WebSite Posts has different type of iframe tags:
eg:
<iframe src="http://examplesite1.tld/somepageordirectory"></iframe>
<iframe src="http://examplesite2.tld/somepageordirectory"></iframe>
<iframe src="http://examplesite3.tld/somepageordirectory"></iframe>
<iframe src="http://examplesite4.tld/somepageordirectory"></iframe>
I Need WordPress Function for get and replace iframe src for specified (eg: examplesite3.tld) domain eg:
<iframe src="http://examplesite1.tld/somepageordirectory"></iframe>
<iframe src="http://examplesite2.tld/somepageordirectory"></iframe>
<iframe src="/embed.php?ref=http://examplesite3.tld/somepageordirectory"></iframe>
<iframe src="http://examplesite4.tld/somepageordirectory"></iframe>
I'm new in WordPress.
Any Help is Highly appreciated and a lot of sorry about my english.
We need the surrounding code to understand how the page is built, not the displayed code.
To do what you're talking about you would use the surrounding html tags and echo the wordpress variable within it, eg:
<iframe src="<?php echo wp_function( 'variable' );?>"></iframe>

Getting dynamic PHP links and iframe to work?

I'm creating a wordpress theme and am having trouble generating a video link to go into an iframe source. I've tried troubleshooting and it seems that the issue is beyond wordpress and I can't actually input any link with PHP to work with iframe. Here's an example for simplicity's sake.
<iframe src="<?php echo 'https://vimeo.com/159120552'; ?>" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
The PHP works as far as I can tell (when I inspect it, the link is in the correct place), but there appears to be a blank web document created in the iframe instead.
Am I doing something wrong or is this a known issue of iframe and PHP?
This issue not related to PHP . Its throwing an error refused to display in a frame because it set 'X-Frame-Options' to 'sameorigin'.
Please refer How to set 'X-Frame-Options' on iframe?

Embedded videos don't show up

I have a web site I'm working on and for some reason some of my videos don't display. The first videos display but the next one's don't.
So first one looks like this:
And the rest look like this:
I know the url's I am using are correct, I dump them to the screen and navigated to them to make sure they weren't broken. This is in chrome, same thing happens in IE.
This is the code I am using to embed:
<iframe width="420" height="315" alt="Jesus Culture" src="<?=$row?>"
frameborder="5" allowfullscreen></iframe>
I'm using similar code to yours for multiple videos on one page,
i.e.
<iframe width="425" height="349" src="http://www.youtube.com/embed/video-code" frameborder="0" allowfullscreen=""></iframe>
Make sure that your urls have the embed format. Also try to place the src value hardcoded (no php) to check whether in that case displaying multiple videos on the page will be an issue.

How to get around This Content cannot be displayed in a frame? (Youtube issue)

I'm trying to keep a database of posted videos on a site I am currently developing. To be able to do this I have to store the URLs of the videos into a database and then I call the url from the database using php and sql by doing this bare in mind I am using this from a php defined area on my homepage. If I use this code it works on other video post sites!
echo '<iframe width="640" height="390" src="', $row['Post_URL'],'"frameborder="0" allowFullScreen></iframe>';
This will not work it says content cannot be displayed in a frame but if I do this it works.
<?php
echo '<iframe width="560" height="315" src="http://www.youtube.com/embed/wardQ7W8hPU" frameborder="0" allowfullscreen></iframe>';
?>
why does the one work properly and the other not? what is a way around this so I can call from the database into php and echo it out so it will display properly on the page?
I got the same problem today. As stated in one of the comments, the problem is the url used...
The iframe embed only works with urls looking like:
http://www.youtube.com/embed/[video_id]
Most of people are using the "share" feature, that generates minified urls like:
http://youtu.be/[video_id]
However, if you look into the "embed" feature, you'll notice that it generates an iframe with src urls like the first example.
So to answer the question, when using iframes to embed, use the src url like the first example.
Try this
<iframe width="640" height="390" src="<?php echo $row['Post_URL'] ?>" frameborder="0" allowFullScreen></iframe>
OR this
<?php
echo "<iframe width='640' height='390' src='{$row['Post_URL']}' frameborder='0' allowFullScreen></iframe>";
?>
OR this
<?php
echo "<iframe width='640' height='390' src='" . $row['Post_URL'] . "' frameborder='0' allowFullScreen></iframe>";
?>
they all are the same and will do the same process.
I'm doing this with dynamic data and it's easier for the client to use the youtube Share link.
So... it's then just a matter of getting the youtube video ID from that url.
// we can't use the "share" link so need to just get the video ID
$youtubePath = parse_url($youtubeShareLink,PHP_URL_PATH);
$youtubeId = str_replace('/','',$youtubePath);
and now we can use the ID in an iframe (adjust width and height per embed options in youtube)
<iframe width="560" height="315" src="//www.youtube.com/embed/<? echo $youtubeId; ?>?rel=0" frameborder="0" allowfullscreen></iframe>

Categories