【发布时间】:2018-09-09 03:10:31
【问题描述】:
我正在编写一些将自定义字段中的信息发布到数据库的代码。
以下代码检查是否存在 $meta_key:
// Apply filters to keys
$this->keys = apply_filters('sc_meta_keys', $this->keys);
// See if the current meta_key is in the array keys
if($this->in_array_recursive($meta_key, $this->keys)) {
if($action == "add") {
//information from array gets added to DB
}
}else{
//Do something else
}
但我不确定如何检查 meta_key 中是否有值,因为如果没有值存在,我不希望 if 语句运行。
该数组将始终具有键,但并非每个帖子都必须填充自定义字段。
【问题讨论】:
标签: php wordpress if-statement multidimensional-array metadata