gpt4 book ai didi

PHP不会显示 "0"值字符串?

转载 作者:行者123 更新时间:2023-11-29 22:32:38 25 4
gpt4 key购买 nike

我正在使用带有 Genesis Framework 的 Wordpress,如果自定义字段的值是“0”,则在获取要显示的值时遇到问题。这些值来自表单,并且 0 值确实位于我数据库的帖子元中。如果我将它们更改为其他内容,它们将完美显示在 single-posttype.php 模板上。但是,如果将它们设置为 0,则不会显示任何内容。我已经提供了我正在使用的代码的示例,是的,我知道我的脏短代码,但没关系。我知道我的位置。帮忙?

 $customField = genesis_get_custom_field('customField');

add_action('hookLocation','myDirtyShortcodes');
function myDirtyShortcodes(){

echo do_shortcode('[some dirtyshortcodehere'.$customField.' more dirty shortcode]');
}

最佳答案

正如 @Machevity 提到的,尝试这种方式:

   add_action('hookLocation','myDirtyShortcodes');
function myDirtyShortcodes(){
$customField = genesis_get_custom_field('customField');
echo do_shortcode('[some dirtyshortcodehere'.$customField.' more dirty shortcode]');
}

关于PHP不会显示 "0"值字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29681174/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com