Wordpress functions are not working inside iframe in wordpress

余生颓废 提交于 2021-02-11 15:39:01

问题


I am using an iframe in wordpress, but the page inside iframe not supporting wordpress functions. the page inside iframe is from the same domain.

Here is what i am trying to do: I am trying to call a css inside iframe page via wordpress function. Below is how i am using iframe tag :

<iframe id="iframeBox" src="<?php echo get_template_directory_uri();?>/iframe/scoreboard_summary.php" sandbox="" FRAMEBORDER="no" ></iframe>

Here is the css calling tag in my page scoreboard_summary.php :

<link type="text/css" rel="stylesheet" href="<?php echo get_template_directory_uri();?>/style.css">

the function get_template_directory_uri() is not working ?

Please let me know what should i need to do? Thanks in advance.


回答1:


iframes are just webpages pulled in and shown in a div. You can't interact with them in that way. PHP has already spit out what was defined by the loops and rules you set. You would want to look into ajax for something like that if you want to talk to the server and bring up new data at an interval, and skip the iframe.

<?php echo 'do this thing' ?> just turns into this thing after the page is loaded. There isn't much to hook into.

If you are just trying to get the stylesheet and apply it to you your page, then I would suggest getting the whole, standard, URL for that stylesheet and skip the template directory uri etc.

Maybe you can explain it better with some code or an example like this one, it's an iframe that refreshes at an interval. Good Luck!

http://jsfiddle.net/sheriffderek/3C9qP/



来源:https://stackoverflow.com/questions/22432953/wordpress-functions-are-not-working-inside-iframe-in-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!