首先显示具有特定选项的所有行,然后显示其余行

时间:2020-06-24 12:12:38

标签: wordpress

我想先显示带有特定选项的帖子,然后在单个查询中显示其余选项。我尝试在线搜索,但未找到任何答案。在StackOverflow上有一个帖子,但是有两个查询。

WP_Query show a specific post and then show the rest

但是我想在一个查询中做到这一点。

查询:

  $page = get_field('promotional_cars', $id);
  $paged = get_query_var('paged') ? get_query_var('paged') : 1;
  $args = array(
    'post_type' => 'car',
    'post_status' => 'publish',
    'post__in'  => $page,
    'posts_per_page' => 10,
    'meta_key' => 'per_month_rent',
    'orderby' => 'meta_value_num',
    'order' => 'asc',
    'paged' => $paged,
  );
  $arr_posts = new WP_Query( $args );
    if ($arr_posts->have_posts()) :
      while ($arr_posts->have_posts()) : $arr_posts->the_post();
           if(get_field('allow_featured', $id)=='Yes'){
              echo "featured";
           } else {
              echo "non featured";
           }
      endwhile;  
    else :
    _e('404 Error: Not Found', '');
    endif; 
 wp_reset_postdata();

能帮我吗?

谢谢

0 个答案:

没有答案