{"id":12966,"date":"2019-07-10T11:02:32","date_gmt":"2019-07-10T11:02:32","guid":{"rendered":"http:\/\/www.wjst.de\/blog\/?p=12966"},"modified":"2019-07-10T11:07:01","modified_gmt":"2019-07-10T11:07:01","slug":"wordpress-url-variable-to-iframe-url","status":"publish","type":"post","link":"https:\/\/www.wjst.de\/blog\/sciencesurf\/2019\/07\/wordpress-url-variable-to-iframe-url\/","title":{"rendered":"Forward WordPress URL variable to iframe URL variable"},"content":{"rendered":"<p>It may not be the best programming idea, but iframes are still quick way to add an existing page into a WordPress hierarchy.<br \/>\nThe are many ways to forward an URL variable to an iframe (php function, plugin, &#8230;) while I think the easiest way is a short javascript<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nurl_string = new URL(window.location.href);\r\nuuid = url_string.searchParams.get(&quot;uuid&quot;);\r\nnew_url_string = 'https:\/\/xxx\/index.php?uuid='+uuid;\r\nel = document.getElementById('iframe');\r\nif (uuid) { el.src = new_url_string };\r\n<\/pre>\n<p>and hook that into wordpress at the end of functions.php<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nadd_action( 'wp_enqueue_scripts', 'myscript' );\r\nfunction myscript() {\r\n\twp_enqueue_script( 'myscript', 'https:\/\/xxx\/myscript.js&quot;', array(), false, true );\r\n}\r\n<\/pre>\n<p>the last wp_enqueue_script parameter is important&#8230;<\/p>\n\n<p>&nbsp;<\/p>\n<div class=\"bottom-note\">\n  <span class=\"mod1\">CC-BY-NC Science Surf , accessed 29.04.2026<\/span>\n <\/div>","protected":false},"excerpt":{"rendered":"<p>It may not be the best programming idea, but iframes are still quick way to add an existing page into a WordPress hierarchy. The are many ways to forward an URL variable to an iframe (php function, plugin, &#8230;) while I think the easiest way is a short javascript url_string = new URL(window.location.href); uuid = &hellip; <a href=\"https:\/\/www.wjst.de\/blog\/sciencesurf\/2019\/07\/wordpress-url-variable-to-iframe-url\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Forward WordPress URL variable to iframe URL variable<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-12966","post","type-post","status-publish","format-standard","hentry","category-computer-software"],"_links":{"self":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/12966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/comments?post=12966"}],"version-history":[{"count":6,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/12966\/revisions"}],"predecessor-version":[{"id":12972,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/12966\/revisions\/12972"}],"wp:attachment":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/media?parent=12966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/categories?post=12966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/tags?post=12966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}