我正在提取自定义帖子产品,我的要求是在
中提取产品使用自定义产品提交的升序。
<?php
#
# rt-theme product loop
#
global $args,$wp_query;
//column
$box_counter = 0;
if(is_tax()) $args = array_merge( $wp_query->query, $args);
$args1['orderby'] = 'wpcf-watt';
$args2['order'] ='ASC';
$args = array_merge($args, $args1);
$args = array_merge($args, $args2);
query_posts($args);
$product = array();
$postCount = 0;
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<?php
//box class
$product[$postCount]['title'] = get_the_title();
$product[$postCount]['thumb'] = find_image_org_path(get_post_meta($post->ID, THEMESLUG.'product_image_url', true));
$product[$postCount]['image'] = @vt_resize( '', $thumb, $w, $h, ''.$crop.'' );
$product[$postCount]['short_desc'] = get_post_meta($post->ID, THEMESLUG.'short_description', true);
$product[$postCount]['permalink'] = get_permalink();
$product[$postCount]['watt'] = get_post_meta($post->ID, 'wpcf-watt', true);
$postCount = $postCount + 1;
?>
<?php endwhile?>
<?php
echo "<pre>";print_r($product);
?>
<?php endif; wp_reset_query();?>
此处 args 是数组
Array
(
[paged] => 2
[taxonomy] => product_categories
[term] => 12-volt-power-inverters
[post_status] => publish
[orderby] => wpcf-watt
[order] => ASC
)
[orderby] =&gt; WPCF瓦
wpcf-watt 是我用于产品的自定义字段。我在自定义帖子产品中使用工具集插件作为自定义字段。
问题是产品不是根据 [orderby] =&gt; wpcf-watt 我不知道如何从数据库中按升序对产品进行排序。