我正试图根据meta_key交易金额对帖子列表进行排序,这将首先显示最高的交易金额,并将其降低到较小的交易金额。这笔交易金额将在1000到900万之间。目前,下面的代码正在根据第一个数字对交易金额进行排序。因此,如果我有一个事务,即6,000和6,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,他们把他们放在一起,而不是先显示600万。交易金额从CMB2中的自定义CMB2中提取。在我的代码中有什么东西是我遗漏的,那就是排序没有识别逗号后面的数量吗?
我的WP_Query
'transactions',
'paged' => $paged,
'posts_per_page' => 50,
'orderby' => array( 'meta_value_num' => 'ASC' ),
'meta_key' => 'deal_amount',
) );
if ( $transaction->have_posts() ) : ?>
have_posts() ) : $transaction->the_post();
$deal_amount = get_post_meta( get_the_ID(), 'deal_amount', true );
$property_type = get_post_meta( get_the_ID(), 'property_type', true );
$property_size = get_post_meta( get_the_ID(), 'property_size', true );
?>
', ''); ?>
The MetaBoxadd_action( 'cmb2_admin_init', 'transactions_metabox' );
function transactions_metabox() {
$prefix = 'transactions_';
$cmb = new_cmb2_box( array(
'id' => $prefix . 'transactions',
'title' => esc_html__( 'Transactions', 'cvcapital' ),
'object_types' => array( 'transactions', ),
) );
$cmb->add_field( array(
'name' => 'Deal Amount',
'id' => 'deal_amount',
'type' => 'text',
'before_field' => ' . esc_html($deal_amount) . ''; ?>
ID, 'loan-type', '', ', ', '' ) ; echo strip_tags($terms_as_text); ?>The MetaBox
A1, 'column' => true, // Display field value in the admin post-listing columns 'before_display' => ' . esc_html($deal_amount) . ''; ?>
ID, 'loan-type', '', ', ', '' ) ; echo strip_tags($terms_as_text); ?>
The MetaBox
A1, ) ); . esc_html($deal_amount) . ''; ?>
ID, 'loan-type', '', ', ', '' ) ; echo strip_tags($terms_as_text); ?>
The MetaBox
A1
发布于 2018-11-27 15:02:14
下面是在“jacobPeattie”的指导下的工作示例。有一次我去掉了逗号,一切都很好。我在交易金额中添加了number_format,以自动添加前面的逗号。
'transactions',
'paged' => $paged,
'posts_per_page' => 50,
'orderby' => array( 'meta_value_num' => 'ASC' ),
'meta_key' => 'deal_amount',
) );
if ( $transaction->have_posts() ) : ?>
have_posts() ) : $transaction->the_post();
$deal_amount = get_post_meta( get_the_ID(), 'deal_amount', true );
$property_type = get_post_meta( get_the_ID(), 'property_type', true );
$property_size = get_post_meta( get_the_ID(), 'property_size', true );
?>
', ''); ?>
. number_format($deal_amount) . ''; ?>
ID, 'loan-type', '', ', ', '' ) ; echo strip_tags($terms_as_text); ?>https://wordpress.stackexchange.com/questions/320277
复制相似问题