[英]Wordpress advanced custom fields plugin is not giving output correctly
I have 2 similar lines of code, the first one works OK but the second is not. 我有2条类似的代码行,第一个行可以,但是第二行则行。
This one works ok and displays the title within the <li></li>
这可以正常工作,并在
<li></li>
显示标题
$output .= '<li>' . the_title() . '</li>';
This one returns an empty <li></li>
and displays the result on top of the page 这将返回一个空的
<li></li>
并将结果显示在页面顶部
$output .= '<li>' . the_field('price') . '</li>';
the_field('price') is a custom wordpress field which i've created by using "Advanced Custom Fields" plugin. the_field('price')是我通过使用“高级自定义字段”插件创建的自定义wordpress字段。 Here is the documentation of the plugin on how to output the data http://www.advancedcustomfields.com/resources/field-types/select/
这是有关如何输出数据的插件文档http://www.advancedcustomfields.com/resources/field-types/select/
In your case, perhaps its better to use get_field() instead of the_field() . 在您的情况下,最好使用get_field()而不是the_field() 。
Here is the difference: 区别在于:
get_field()
will give you the value. get_field()
将为您提供值。 the_field()
will print the result directly but return NULL. the_field()
将直接打印结果,但返回NULL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.