【问题标题】:cant access get_post_meta key value无法访问 get_post_meta 键值
【发布时间】:2017-01-06 10:43:21
【问题描述】:

我使用 woocomerce 产品对结果表进行了一些修改,并且我想从 post meta key unique_code 添加一些额外信息,但它没有按应有的方式工作:

$uniquecode = get_post_meta( $post->ID, 'unique_code' , true ); 
$result.='<td>' . $uniquecode. '</td>'; (this result goes in a td)

没有打印出来

我也试过了

$mymeta = get_post_meta( $post->ID, 'unique_code', false);

foreach($mymeta as $array) {
    if(isset($array['unique_code'])) {
        $name = $array['unique_code'];
        break;
    }
}

$result.='<td>' . $name . print_r($name ) . '</td>';(this result goes in a td)

数组打印 1。

【问题讨论】:

    标签: post get woocommerce meta


    【解决方案1】:

    终于解决了

    $key_name = get_post_custom_values($key = 'unique_code');

    $result.='' 。 '标题: ' 。 $key_name[0] 。 '';

    :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-03
      • 1970-01-01
      • 2016-03-11
      • 2021-01-17
      • 2019-10-07
      • 2018-03-27
      相关资源
      最近更新 更多