如何在WordPress中显示字段的值?PHP

时间:2015-09-04 12:45:55

标签: php html css wordpress

我有这个网站:

link

我安装了插件类型,并尝试使用此代码在div中显示值字段。

<div class="selectat">
<div>
<?php $variable = do_shortcode("[types field='descriere' ]");?>
<?php echo $variable;?>

</div>
</div>

我的领域被称为descriere ..我把图片看得更清楚。

enter image description here

不幸的是这个空白,虽然我在网站上看不到任何东西,基本上我的div是空的..

enter image description here

我编写代码的方式有误吗? 我必须调用另一个函数吗?

你可以帮我解决这个问题吗?

提前致谢!

1 个答案:

答案 0 :(得分:0)

您不需要使用任何可以使用的短代码

<div class="selectat">

    <div>
        <?php $variable = the_field( 'descriere' );
        <?php echo $variable;?>
    </div>
</div>

但是如果你想直接回复代码,你可以使用get_field(&#39;&#39;)将值直接回显到页面。

<div class="selectat">

    <div>
         <?php $variable = get_field( 'descriere' );
    </div>
</div>