Set embedded iframe src dynamically depending on variable in url - iframe

i would like to dynamically set the src of my iframe depending on a parameter in the Website-URL.
Examples:
www.example.com?source=random
The iframe should load iframe 1
www.example.com?source=evenmorerandom
The iframe should load iframe 2
Could someone help me with the correct code for that?
Thank you for your help!
Rob

If www.example.com is a PHP page:
<html><body>
<?php print "<iframe src=' . $_GET["source"] . "'>"; ?>
</body></html>

Related

Change the Path of wordpress featured image

I am trying to change the current path obtained bywp_get_attachment_url(get_post_thumbnail_id)
Now I get the uri as http://localhost/velocity/wordpress/wp-content/themes/velocity/images/pic01.jpg.
but I want to change the uri as http://newhost/velocity/wordpress/wp-content/themes/velocity/images/pic01.jpg
any idea?
The image you're referring to isn't an attachment image...it's a theme asset.
If you're properly including this in your template, changing hosts won't be a problem and the URL will automatically update. The following is an example of how you could be including the src in your template, using get_stylesheet_directory_uri():
<img src="<?php echo get_stylesheet_directory_uri() . '/images/pic01.jpg'; ?>">

Wordpress, embed page within page

I'm trying to find a solution to embed a page within a page template. I found this code on the Internet. Obviously, this only adds the content of a page, not the whole page (including header/footer etc.)
<?php
$id = $redux_demo['special-errorpage'];
$p = get_page($id);
echo apply_filters('the_content', $p->post_content);
?>
Anyone an idea how to tweak the code to make it do what I want it to do?
As always, many thanks in advance.
for import a page inside a page, i would use IFRAME html tag,
it could be dirty if you don't take care of what kind of page you happend to your current page.
i let you the mdn doc on this iframe!
https://developer.mozilla.org/en/docs/Web/HTML/Element/iframe

taxonomy.php doesn't display images from "../image/" folder

i have some images loading in the header (header.php) from the location "../images/"
code is
<div class="header">
<img src="../images/headerimg.gif" alt=""/>
</div>
while the pages and custom post type load the image correctly from the location ..
the taxonomy.php doesn't load the image at all instead shows the cross sign which image is there but not loaded
plz help
In wordpress, you should never use such relative paths.
You should use one of the Built-in path functions , like get_template_directory_uri()
<?php echo get_template_directory_uri(); ?>/images/headerimg.gif">
or in the event you want to be included or ovverriden by child theme use get_stylesheet_directory_uri()
All this of course assumes that the images are in a sub-folder called images under the main theme folder. ( which is how it is supposed to be )
In case that the image is an Uploaded image , it should be referenced by the ID or the URL that is supplied from the upload . Even in the case you do not want to do so for some ( probably wrong ) reason , you should then also use wp functions like for example wp_upload_dir()

How to add an iframe to Wordpress sidebar?

I am using the default TwentyEleven theme, and I added the following code to sidebar.php, but it does not work (I get a 310 error)
<iframe src="frame.html" name="test" height="600" width="180"></iframe>
iframe.html is located in /themes/twentyeleven folder, so it should be working (at least on a regular website).
Is it necessary to use some kind of widget plugin in order to get it to work. What can be preventing the iframe from showing up on the website?
Thank you.
You need to hit the file via an http request, not via the local path.
<iframe src="<?php echo ( get_site_url() . '/wp-content/themes/twentyeleven/iframe.html' ); ?>" />
You Should use get_bloginfo('template_directory') before giving path.......
try using
{
<iframe src="<?php echo get_theme_root(); ?>/frame.html" name="test" height="600" width="180"></iframe>
}
Try reading this
http://codex.wordpress.org/Function_Reference/get_theme_root

Embed HTML page as header and footer to my HTML page (Subdomain)?

I am doing a DNN (asp .net) website which is expected to run as a sub domain website to a parent website running on PHP. To explain it with an example I am building subdomain.example.com which is being built using asp .net technology (DotNetNuke) the example.com is running on PHP (I guess wordpress).
I have to embed a header (banner section http://example.com/header_section_only) and a footer (site map http://example.com/footer_section_only) from the parent website (example.com) to the sub-domain website (subdomain.example.com). As banner advertisement are dynamic in nature the height of header page might change on a day to day biases.
I had proposed to use IFrame but variable size of the page create a lot of problem, are there other solution to this problem? Can anyone suggest me other alternatives?
You can use this way:
In your index.php or the main file, you can include the header_section_only this way:
<body>
<?php
echo file_get_contents("http://example.com/header_section_only");
?>
<!-- Body Contents -->
<?php
echo file_get_contents("http://example.com/footer_section_only");
?>
</body>
If the files are relatively present:
<body>
<?php
include ("header.inc");
?>
<!-- Body Contents -->
<?php
include ("footer.inc");
?>
</body>

Resources