Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么wordpress get_post_meta不返回任何内容,而我的数据库有值?_Wordpress - Fatal编程技术网

为什么wordpress get_post_meta不返回任何内容,而我的数据库有值?

为什么wordpress get_post_meta不返回任何内容,而我的数据库有值?,wordpress,Wordpress,或 它返回[“”] 用另一个值更改键,它将返回数据库中的值。尝试下面的代码 $attribute_settings = array(); $attribute_settings[] = get_post_meta( 12785, 'attribute_settings', true ); return $attribute_settings; 您提到,如果更改密钥,您将获得所需的值。查看您的屏幕截图,您已经获得了属性设置的重复键。我不确定您是如何在其中获得重复密钥的(您是否直接在phpMy

它返回[“”] 用另一个值更改键,它将返回数据库中的值。

尝试下面的代码

$attribute_settings = array();

$attribute_settings[] = get_post_meta( 12785, 'attribute_settings', true );

return $attribute_settings;

您提到,如果更改密钥,您将获得所需的值。查看您的屏幕截图,您已经获得了
属性设置的重复键。我不确定您是如何在其中获得重复密钥的(您是否直接在phpMyAdmin中添加了它们?如果记录存在,使用将更新记录)

现在,我以前没有看到过存在重复的
post\u id:meta\u key
对的情况,但我敢打赌,自从它第一次出现以来,它将返回
NULL
值。删除那个条目,你应该是好的


文档和功能参考 作用 链接描述
update\u post\u meta()
return array( get_post_meta("12785", 'attribute_settings', true));
$attribute_settings = array();

$attribute_settings[] = get_post_meta( 12785, 'attribute_settings', true );

return $attribute_settings;