Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php文件(wordpress)的回显中使用html和php的组合_Php_Html_Wordpress_Echo - Fatal编程技术网

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

在php文件(wordpress)的回显中使用html和php的组合,php,html,wordpress,echo,Php,Html,Wordpress,Echo,如果有人能在这里帮助我,我将不胜感激。我想在我的Wordpress站点上的一个php文件的echo部分调用一个短代码。我试过一些方法,但似乎都不管用 下面是当前的代码 <?php if ( is_home() or is_front_page()) {echo '<div class="section group"> <div class="col span_1_of_2"> <a href="http:

如果有人能在这里帮助我,我将不胜感激。我想在我的Wordpress站点上的一个php文件的echo部分调用一个短代码。我试过一些方法,但似乎都不管用

下面是当前的代码

<?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>' ; }
我想用一个短代码替换下面的一位

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

<?php echo do_shortcode("[shortcode]"); ?>
但是我在应该出现短代码的地方什么都没有

还尝试在短代码调用前后转义带有“”标记的html,但页面随后无法加载

我已经在一个页面中添加了短代码,它是页面顶部的焦点训练图像,而不是页眉中的图像。如果我查看源代码并复制短代码的html,然后将其放入我的php文件中,一切都会很好

非常感谢您的帮助。 谢谢

这很有效

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

不是答案,但您需要使用此运算符| |,而不是在第一行使用或。例如:如果is|u home | is|u首页{你的短码是什么?我肯定不是[shortcode]谢谢你的回复,短码是[cm_ad_id=1]