【发布时间】:2019-12-07 05:27:12
【问题描述】:
我创建了一个函数来向 woocommerce 产品管理屏幕添加一列,然后获取键 ae_cost_pkr 的元值并将 5 添加到它并在新创建的列中回显结果。它有效,但我遇到了一个问题,即原始元值附加到相邻列。我做错了什么?
在这张图片中可以看到错误:ibb.co/n3y6n2n
我的功能是:
// add
add_filter( 'manage_edit-product_columns', 'my_total_sales_1', 20 );
// populate
add_action( 'manage_posts_custom_column', 'my_total_sales_2' );
function my_total_sales_1( $col_th ) {
// create colunm
return wp_parse_args( array( 'ae_cost_pkr' => 'AE Price' ), $col_th );
}
// add 5 to the meta value and display in column
function my_total_sales_2( $column_id ) {
if( $column_id == 'ae_cost_pkr' )
$re = get_post_meta( get_the_ID(), 'ae_cost_pkr', true );
echo $re + 5;
}
【问题讨论】:
标签: wordpress woocommerce