【发布时间】:2015-05-02 13:28:45
【问题描述】:
我想在 word press 中的 header.php 模板中使用此代码来使用 ACF 插件字段。
但它不起作用。例如href 属性不起作用。
这是我的代码:
echo '<div align="center">';
//Rule Adress
if (the_field("rule") != 'http://' || the_field("rule") != '') {
echo '<a href="' . the_field('rule') . '" role="button" class="Button Button--error" title="Rules" rel="nofollow" target="_blank"><i class="fa fa-fw fa-check"></i>Rules</a>';
}
//Cost
if (the_field("cost") != '0' || the_field("rule") != '') {
echo '<a role="button" class="Button Button--info" style="cursor: default;"><i class="fa fa-fw fa-shopping-cart"></i>Cost: ' . the_field('cost') . ' Dolor</a>';
}
//Demo
if (the_field("demo") != 'http://' || the_field("demo") != '') {
echo '<a href="' . the_field('demo') . '" role="button" class="Button Button--primary" title="Demo" rel="nofollow" target="_blank"><i class="fa fa-fw fa-heart"></i>Demo</a>';
} else {
echo '<a role="button" class="Button Button--primary" title="Demo" style="cursor: default;"><i class="fa fa-fw fa-heart"></i>Demo</a>';
}
//Shots
if (the_field("shots") != 'http://' || the_field("shots") != '') {
echo '<a href="' . the_field('shots') . '" role="button" class="Button Button--warning" title="Shots" rel="nofollow" target="_blank"><i class="fa fa-fw fa-desktop"></i>Shots</a>';
} else {
echo '<a role="button" class="Button Button--warning" title="Shots" style="cursor: default;"><i class="fa fa-fw fa-desktop"></i>Shots</a>';
}
echo '</div">';
is-product、rule、cost、demo 和 shot 字段是我在 wp-admin 中定义的字段。
请帮我解决这个问题。
【问题讨论】:
标签: php string wordpress advanced-custom-fields