[wp-trac] [WordPress Trac] #54436: Sorting issue- when sorting via a custom meta key

WordPress Trac noreply at wordpress.org
Sat Nov 13 20:52:05 UTC 2021


#54436: Sorting issue- when sorting via a custom meta key
------------------------------+------------------------------
 Reporter:  prashantinfozion  |       Owner:  (none)
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  General           |     Version:  5.5.2
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:
------------------------------+------------------------------
Description changed by sabernhardt:

Old description:

> So, I created a new meta key with the name "_tstock" and stored numeric
> values in it, used the code below for sorting:
> **$args['orderby'] = 'meta_value_num';
> $args['order'] = 'DESC';
> $args['meta_key'] = '_tstock';**
> The products tend to repeat after switching the page if the value of
> _tstock of the last product is similar to first product on the next page.
> Elaborating a bit more :-
> Let's assume that there are 10 products with the _tstock value equal to
> one and 5 products are displayed on the first page while the rest 5 are
> displayed on second page.
> The total number of the product will not change instead some of the
> products from the first page will be displayed on the second page
> replacing the ones that should be displayed.

New description:

 So, I created a new meta key with the name `_tstock` and stored numeric
 values in it, used the code below for sorting:
 {{{
 $args['orderby'] = 'meta_value_num';
 $args['order'] = 'DESC';
 $args['meta_key'] = '_tstock';
 }}}
 The products tend to repeat after switching the page if the value of
 `_tstock` of the last product is similar to first product on the next
 page.

 Elaborating a bit more :-
 Let's assume that there are 10 products with the `_tstock` value equal to
 one and 5 products are displayed on the first page while the rest 5 are
 displayed on second page.
 The total number of the product will not change instead some of the
 products from the first page will be displayed on the second page
 replacing the ones that should be displayed.

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54436#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list