将php与html标记混合使用
我正在尝试实现下面的代码,但结果是什么也没有显示将php与html标记混合使用,php,wordpress,Php,Wordpress,我正在尝试实现下面的代码,但结果是什么也没有显示 <li class="cleanup">Garantie:<span><?php (get_post_meta(get_the_ID(), 'Garantie', true); ?> Jahre</span><?php echo (get_post_meta(get_the_ID(), 'Garantie', true) >= 2) ? ('<span class="pro_co
<li class="cleanup">Garantie:<span><?php (get_post_meta(get_the_ID(), 'Garantie', true); ?> Jahre</span><?php echo (get_post_meta(get_the_ID(), 'Garantie', true) >= 2) ? ('<span class="pro_con pro"><i class="fa fa-check"></i>Lange Garantie: ' . <?php (get_post_meta(get_the_ID(), 'Garantie', true)); ?> . ' Jahre</span>') : ('<span class="pro_con pro"><i class="fa fa-check"></i>Standart Garantie: ' . <?php (get_post_meta(get_the_ID(), 'Garantie', true)); ?> . ' Jahre</span>'; ?>) </li>
Garantie:如果有一个额外的括号,请更改为
<?php get_post_meta(get_the_ID(), 'Garantie', true); ?>
// ^ it was here
//^就在这里
顺便说一句,您必须在devel env上登录,日志帮助很大。如果有额外的括号,请更改为
<?php get_post_meta(get_the_ID(), 'Garantie', true); ?>
// ^ it was here
//^就在这里
顺便说一句,您必须登录到devel env,日志帮助很大。您在三元运算符中有一些额外的结束标记?>
php
修改代码:
<li class="cleanup">Garantie:
<span>
<?php get_post_meta(get_the_ID(), 'Garantie', true); ?> Jahre
</span>
<?php
echo (get_post_meta(get_the_ID(), 'Garantie', true) >= 2) ?
('<span class="pro_con pro"> <i class="fa fa-check"></i>Lange Garantie: ' .
(get_post_meta(get_the_ID(), 'Garantie', true)) . ' Jahre</span>') :
('<span class="pro_con pro"> <i class="fa fa-check"></i>Standart Garantie: ' .
(get_post_meta(get_the_ID(), 'Garantie', true)) . ' Jahre</span>' ) ;
?>
</li>
Garantie:
贾尔
在三元运算符中有一些额外的结束标记
修改代码:
<li class="cleanup">Garantie:
<span>
<?php get_post_meta(get_the_ID(), 'Garantie', true); ?> Jahre
</span>
<?php
echo (get_post_meta(get_the_ID(), 'Garantie', true) >= 2) ?
('<span class="pro_con pro"> <i class="fa fa-check"></i>Lange Garantie: ' .
(get_post_meta(get_the_ID(), 'Garantie', true)) . ' Jahre</span>') :
('<span class="pro_con pro"> <i class="fa fa-check"></i>Standart Garantie: ' .
(get_post_meta(get_the_ID(), 'Garantie', true)) . ' Jahre</span>' ) ;
?>
</li>
Garantie:
贾尔
试试这个:
<li class="cleanup">Garantie:<span><?php (get_post_meta(get_the_ID(), 'Garantie', true); ?> Jahre</span>
<?php echo (get_post_meta(get_the_ID(), 'Garantie', true) >= 2) ? '<span class="pro_con pro"><i class="fa fa-check"></i>Lange Garantie: ' . get_post_meta(get_the_ID(), 'Garantie', true) . ' Jahre</span>' : '<span class="pro_con pro"><i class="fa fa-check"></i>Standart Garantie: ' . get_post_meta(get_the_ID(), 'Garantie', true) . ' Jahre</span>'; ?> </li>
Garantie:试试这个:
<li class="cleanup">Garantie:<span><?php (get_post_meta(get_the_ID(), 'Garantie', true); ?> Jahre</span>
<?php echo (get_post_meta(get_the_ID(), 'Garantie', true) >= 2) ? '<span class="pro_con pro"><i class="fa fa-check"></i>Lange Garantie: ' . get_post_meta(get_the_ID(), 'Garantie', true) . ' Jahre</span>' : '<span class="pro_con pro"><i class="fa fa-check"></i>Standart Garantie: ' . get_post_meta(get_the_ID(), 'Garantie', true) . ' Jahre</span>'; ?> </li>
Garantie:像这样的东西怎么样:
<li class="cleanup">
Garantie:
<span>
<?php echo get_post_meta(get_the_ID(), 'Garantie', true); ?> Jahre
</span>
<?php
if(get_post_meta(get_the_ID(), 'Garantie', true) >= 2){
echo '<span class="pro_con pro"><i class="fa fa-check"></i>Lange Garantie: ';
echo get_post_meta(get_the_ID(), 'Garantie', true);
}else{
echo '<span class="pro_con pro"><i class="fa fa-check"></i>Standart Garantie: ';
echo get_post_meta(get_the_ID(), 'Garantie', true);
}
echo " Jahre</span>";
?>
</li>
加兰蒂:
贾尔
毕竟,可读性很重要……像这样的东西怎么样:
<li class="cleanup">
Garantie:
<span>
<?php echo get_post_meta(get_the_ID(), 'Garantie', true); ?> Jahre
</span>
<?php
if(get_post_meta(get_the_ID(), 'Garantie', true) >= 2){
echo '<span class="pro_con pro"><i class="fa fa-check"></i>Lange Garantie: ';
echo get_post_meta(get_the_ID(), 'Garantie', true);
}else{
echo '<span class="pro_con pro"><i class="fa fa-check"></i>Standart Garantie: ';
echo get_post_meta(get_the_ID(), 'Garantie', true);
}
echo " Jahre</span>";
?>
</li>
加兰蒂:
贾尔
毕竟,可读性很重要……可能是因为您忘记回显返回的值?站点是否为空?可能是因为您忘记回显返回的值?网站是空白的吗?是的,他可能忘记了回音,这就是为什么有括号echo
可能在get\u post\u meta
中。不,他自己使用了一个回音,可能只是部分地复制和粘贴了它。数据:以get
开头的函数不应该回音。如果它与任何内容相呼应,则应将其命名为print\
;但话说回来,是Wordpress;-)是的,他可能忘记了回音,这就是为什么括号echo
可能在get\u post\u meta
中。不,他自己使用了一个回音,可能只是部分地复制和粘贴了它。数据:以get
开头的函数不应该回音。如果它与任何内容相呼应,则应将其命名为print\
;但话说回来,是Wordpress;-)