admin管理员组文章数量:1327843
Hi all I'm kind of new to WordPress. I have created an override for WooCommerce and I'm trying to echo a DOM element with an Advanced Custom Field in it.
I've used this code.
<?php
if (the_field('price_per_unit'))
{
echo '<span class="unit-price">Price per unit: ' . the_field('price_per_unit') . '</span>';
}
echo '<p>Test</p>';
?>
The custom field arrives, so I know I'm in the right file, but the <p>
does not and the word "Test" does not.
Can anyone explain why this happens and how I can get my DOM elements to appear?
I thought it might be some kind of a sanitiser to I tried echoing just the word without any HTML but that also didn't work.
Many thanks
Hi all I'm kind of new to WordPress. I have created an override for WooCommerce and I'm trying to echo a DOM element with an Advanced Custom Field in it.
I've used this code.
<?php
if (the_field('price_per_unit'))
{
echo '<span class="unit-price">Price per unit: ' . the_field('price_per_unit') . '</span>';
}
echo '<p>Test</p>';
?>
The custom field arrives, so I know I'm in the right file, but the <p>
does not and the word "Test" does not.
Can anyone explain why this happens and how I can get my DOM elements to appear?
I thought it might be some kind of a sanitiser to I tried echoing just the word without any HTML but that also didn't work.
Many thanks
Share Improve this question asked Jul 30, 2020 at 13:46 EoinEoin 1156 bronze badges1 Answer
Reset to default 1Thats odd - it works ok here if I simulate this as a text field but other field types may cause a problem.
Try replacing 'the_field()' with 'get_field()' in your code.
If that doesn't work - how is your field setup? Text, Number, Date etc...
本文标签: advanced custom fieldsOverride not echoing my string or dom element
版权声明:本文标题:advanced custom fields - Override not echoing my string or dom element 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742220487a2435364.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论