【问题标题】:How can I get post ID in each quick edit item如何在每个快速编辑项目中获取帖子 ID
【发布时间】:2020-04-20 17:47:22
【问题描述】:

我必须将一些参数回显到 woocommerce 快速编辑行。 (编辑器无需打开 woocommerce 产品就可以更轻松地决定放什么价格。)

wc_get_product_terms 是获取精确参数的好功能,但我需要那里发布 ID。 使用 add_action( 'woocommerce_product_quick_edit_end' 我可以将其添加到快速编辑底部。

有谁知道,如何用php实现post id? 一半的代码在这里:

add_action( 'woocommerce_product_quick_edit_end', function () {

    //how to get the post id in each quick edit row with php?

    $height = array_shift( wc_get_product_terms( $post->ID, 'pa_height', array( 'fields' => 'names' ) ) );
    $width  = array_shift( wc_get_product_terms( $post->ID, 'pa_width', array( 'fields' => 'names' ) ) );
    $radius    = array_shift( wc_get_product_terms( $post->ID, 'pa_radius', array( 'fields' => 'names' ) ) );


} );

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    您是否尝试过get_the_id() 而不是$post->ID?可能值得一试。 参考:https://developer.wordpress.org/reference/functions/get_the_id/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-05
      • 2023-03-19
      • 2017-02-04
      • 2020-08-27
      • 2022-01-20
      • 1970-01-01
      • 2022-11-23
      • 2011-01-20
      相关资源
      最近更新 更多