简体   繁体   English

排序查询 ASC 给出错误顺序

[英]Sorting query ASC giving wrong order

I am creating a simple Query that should query through a meta value containing a number.我正在创建一个简单的查询,它应该通过包含数字的元值进行查询。 1 should be first, 2 should be 2nd and 3 should be 3rd. 1应该是第一,2应该是第二,3应该是第三。

For some reason, it comes out like 1, 3, 2 in my query.出于某种原因,它在我的查询中显示为 1、3、2。 What am I missing??我错过了什么??

$args = array(
      'post_type'      => 'x-portfolio',
      'posts_per_page' => $count,
      'paged'          => $paged,
      'orderBy'        => 'meta_value_num',
      'meta_key'       => 'liste_nr',
      'order'          => 'asc',
      'tax_query'      => array(
        array(
          'taxonomy' => 'portfolio-category',
          'field'    => 'term_id',
          'terms'    => $filters,
        ),
        array(
          'taxonomy' => 'portfolio-category',
          'field'    => 'name',
          'terms'    => 'Accessories',
          'operator' => 'NOT IN'
        )
      )
    );

I've run into this before when a CPT, plugin etc has done a custom query and they never reset and it can completely override yours.我之前遇到过这种情况,当 CPT、插件等进行自定义查询时,它们从不重置,它可以完全覆盖您的查询。

Try dropping wp_reset_query() before it and make sure you are using it after.尝试在它之前删除 wp_reset_query() 并确保你在之后使用它。

https://developer.wordpress.org/reference/functions/wp_reset_query/ https://developer.wordpress.org/reference/functions/wp_reset_query/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM