【发布时间】:2019-05-10 14:34:41
【问题描述】:
我正在使用 WordPress ACF 插件 填充一个 WordPress HTML 表格和这个功能:(我认为这是一个一般 PHP 问题)
add_shortcode('custom_acf',custom_acf_callback);
function custom_acf_callback ($atts = '')
{
$value = shortcode_atts( array(
'my_field' => '',
), $atts );
//the main part starts from here:
if ($custom_acf_value){
return $custom_acf_value;
}
else {
//and the problem is here:
return '';
}
我正在使用这个棘手的 css 代码隐藏空表格单元格:
td:empty {
display: none;
}
问题是不会隐藏空单元格,因为表格单元格有一个默认值,即我的简码,我尝试使用:
return NULL;
并且也简单地使用“return”,但它们不会在表格单元格中返回空。注意 css 单独测试并且没有问题,我怎样才能返回真正的 empty 价值?
【问题讨论】:
-
返回一个空数组怎么样,比如
return array()或return []ping 我,如果它可以进入一个完整的答案。 -
如果返回“true”空值,“默认值”如何在表格单元格中结束?
-
@DimitriosDesyllas 谢谢你,但它不起作用,因为无法处理数组并在表格单元格中打印“array()”字符串
-
不使用else块怎么样?那有什么作用?
-
@Manjunath 没有区别也不起作用
标签: php wordpress html-table advanced-custom-fields