Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.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
Php Wordpress自定义字段钩子不工作_Php_Html_Wordpress - Fatal编程技术网

Php Wordpress自定义字段钩子不工作

Php Wordpress自定义字段钩子不工作,php,html,wordpress,Php,Html,Wordpress,我试图在Wordpress(Woocommerce)上为产品添加更多字段。 我添加了如下html字段: <tr> <td><input class="backend_price_accommodatie" name="g/w/l_prijs" type="text" placeholder="g/w/l prijs" width="10"></td> <td><input class="backend_price_

我试图在Wordpress(Woocommerce)上为产品添加更多字段。 我添加了如下html字段:

<tr>
    <td><input class="backend_price_accommodatie" name="g/w/l_prijs" type="text" placeholder="g/w/l prijs" width="10"></td>
    <td><input class="backend_price_accommodatie" name="t/t/i_prijs" type="text" placeholder="Telefoon/tv/internet prijs" width="10"></td>
    <td><input class="backend_price_accommodatie" name="heffingen_prijs" type="text" placeholder="Heffingen prijs" width="10"></td>
    <td><input class="backend_price_accommodatie" name="verzekering_prijs" type="text" placeholder="Woonverzekering prijs" width="10"></td>
</tr>

我错过什么了吗?这看起来很简单,但似乎并没有节省任何东西。或者由于某种原因,它没有在字段中显示保存的信息。

在保存帖子时,不需要添加“\u post\u meta()”,因为更新“\u post\u meta()”将创建元字段(如果不存在)或更新现有元字段(如果存在)

要在仪表板中显示,您需要提取这些元字段值并显示它们

比如说,

在元框中,您添加了回调函数和额外字段

<tr>
    <td><input class="backend_price_accommodatie" name="g/w/l_prijs" type="text" placeholder="g/w/l prijs" width="10"></td>
    <td><input class="backend_price_accommodatie" name="t/t/i_prijs" type="text" placeholder="Telefoon/tv/internet prijs" width="10"></td>
    <td><input class="backend_price_accommodatie" name="heffingen_prijs" type="text" placeholder="Heffingen prijs" width="10"></td>
    <td><input class="backend_price_accommodatie" name="verzekering_prijs" type="text" placeholder="Woonverzekering prijs" width="10"></td>
</tr>

使用下面的代码

global $post;

<tr>
    <td><input class="backend_price_accommodatie" name="g/w/l_prijs" type="text" placeholder="g/w/l prijs" width="10" value="<?php echo get_post_meta( $post->ID, 'g/w/l_prijs', true); ?>"></td>

...

</tr>
global$post;

顺便问一下,
$globals
是什么?1)如果您只能使用update\u post\u meta,为什么要使用add\u post\u meta和update\u post\u meta?2) 条件是否总是返回true,这就是为什么没有将值添加到数据库中?如果它不存在,您也不需要使用
add\u post\u meta
update\u post\u meta
将为您添加它。也许我需要从数据库中获取值并在输入字段中显示它?我在哪里可以找到数据库中的值?谢谢!我有预感是这样的。我尝试在数据库中查找是否正在更新,但找不到字段:/。您可以在“wp_postemta”表中找到元字段值。只需尝试此查询:从数据库中的“%g/w/l\u prijs%”中选择*FROM
wp\u postemta
WHERE
meta\u key
global $post;

<tr>
    <td><input class="backend_price_accommodatie" name="g/w/l_prijs" type="text" placeholder="g/w/l prijs" width="10" value="<?php echo get_post_meta( $post->ID, 'g/w/l_prijs', true); ?>"></td>

...

</tr>