我有这个网站:
我安装了插件 Types 并尝试使用此代码在 div 中显示值字段。
<div class="selectat">
<div>
<?php $variable = do_shortcode("[types field='descriere' ]");?>
<?php echo $variable;?>
</div>
</div>
我的领域叫descriere..我放张图看的更清楚
不幸的是,虽然我在网站上没有看到任何东西,而且基本上我的 div 是空的,但这个空白..
是不是我写代码的方式不对? 我必须调用另一个函数吗?
你能帮我解决这个问题吗?
提前致谢!
最佳答案
你不需要使用任何你可以使用的简码
<div class="selectat">
<div>
<?php $variable = the_field( 'descriere' );
<?php echo $variable;?>
</div>
</div>
但如果您想立即回显代码,您可以使用 get_field('') 将值直接回显到页面。
<div class="selectat">
<div>
<?php $variable = get_field( 'descriere' );
</div>
</div>
关于php - 如何在 WordPress 中显示字段的值?PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32398452/