douliang4858 2014-07-10 09:25
浏览 304

在php文件中使用回显的html和php的组合(wordpress)

I'd be most grateful if someone could help me out here. I'd like to call a shortcode in a echo section, in a php file on my Wordpress site. I've tried a few things but nothing seems to work.

Here is the current code (working)

<?php
if ( is_home() or is_front_page()) {echo '<div class="section group">
            <div class="col span_1_of_2">
                <a href="http://www.ptmagazine.co.uk/testsite/"><img src="http://www.ptmagazine.co.uk/testsite/wp-content/uploads/2013/12/PT-Magazine-Web-Logo.jpg"></a>
            </div>
            <div class="col span_1_of_2">
        <a href="http://www.focus-training.com/"><img src="http://www.ptmagazine.co.uk/testsite/wp-content/uploads/ads/header.jpg" /></a>
            </div>
        </div>
</div>
</div>' ; }

I'd like to replace the below bit with a shortcode

<a href="http://www.focus-training.com/"><img src="http://www.ptmagazine.co.uk/testsite/wp-content/uploads/ads/header.jpg" /></a>

I've tried the usual

<?php echo do_shortcode("[shortcode]"); ?>

but I end up with nothing where the shortcode should appear

Also tried escaping the html with ' ' marks just before and after the shortcode call but the page then fails to load.

I've added the shortcode to a page here http://www.ptmagazine.co.uk/testsite/about-us/ (its the focus-training image at the top of the page, not the one in the header) and if I view source and copy the html for the shortcode and then put it in my php file all works well.

Any assistance greatly appreciated. Thanks

  • 写回答

1条回答 默认 最新

  • douzongluo7542 2014-07-10 20:30
    关注

    This worked a treat

    ' . do_shortcode( '[cm_ad_changer campaign_id="1"]' ) . '
    
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么