Wordpress:在查询中对查询进行排序/排序

时间:2015-11-05 23:24:39

标签: php wordpress

我有一个Wordpress函数,它在自定义帖子类型上使用WP_Query,然后在显示结果的循环中,每个结果都有一个get_posts查询,用于获取结果的子帖子。我正在尝试订购子帖,但没有任何工作,他们按照菜单顺序。有人知道如何在查询中订购查询吗?

以下是基本代码:

// Query - Get all of the themes
remove_all_filters('posts_orderby');
$the_query = new WP_Query(array(
  'post_type'      => 'theme',
  'posts_per_page' => -1,
  'meta_key'       => 'wpcf-theme-age-field',
  'orderby'        => 'meta_value',
  'order'          => ASC
) );

// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();

// Gets the sessions posts that are children of this theme AND are within the season parameter
$childargs = array(
  'post_type'   => 'class-session',
  'numberposts' => -1,
  'meta_query'  => array(
    'relation'  => 'AND',
    array('key' => '_wpcf_belongs_theme_id', 'value' => $postid ),
    array('key' => 'wpcf-edu-season', 'value' => $season ),
  'meta_key'    => 'wpcf_day_of_the_week',
  'orderby'     => 'meta_value',
  'order'       => 'ASC',
  )
);

$child_posts = get_posts($childargs);

0 个答案:

没有答案