开发者

Add php element to custom page in Wordpress

I'm trying to customize a wordpress page to include an iframe which give the users a link to there download. We're using wordpress 2.9.2 with the Thesis theme 1.51. I've been trying to use thesis hooks but appears that the php is stripped from the output. Help? Suggested alternatives?

Code from custom_functions.php:

    function add_ejunkie_download_link () {
is_page('slug-url-of-page') {
?>

<?php
echo '<iframe src="https://www.e-junkie.com/ecom/rp.php?noredirect=true&client_id=CID&txn_id=' . htmlspecialchars($_GET["txn_id"]) . '" width="100%" frameborder="0" height="50px"></iframe>开发者_开发技巧;';
?>

<?php
   }
}
remove_action('thesis_hook_custom_template', 'thesis_hook_custom_template');
add_action('thesis_hook_custom_template', 'add_ejunkie_download_link');


Though not as elegant as custom hook in custom_functions.php, Thesis Open Hook WordPress › Thesis OpenHook « WordPress Plugins is an easy way to add hooks with executable code in them.


Why the remove_action call? I really don't think you need it.

The PHP can't be stripped from the output, because it's just that... PHP. It's parsed at runtime, so it's not stripped, it's executed.

I'm guessing you just want to print the iframe when Thesis calls the thesis_hook_custom_template hook?

Have you double checked this hook is actually getting called, and that it's getting called where you expect it to?

Then try simplifying your hooked function with this;

 function add_ejunkie_download_link() {
     if (is_page('slug-url-of-page')):
 ?>

 <iframe src="https://www.e-junkie.com/ecom/rp.php?noredirect=true&client_id=CID&txn_id=' . htmlspecialchars($_GET["txn_id"]) . '" width="100%" frameborder="0" height="50px"></iframe>

 <?php
     endif;
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜