Make WordPress Core

Opened 19 months ago

Last modified 19 months ago

#54436 new defect (bug)

Sorting issue- when sorting via a custom meta key

Reported by: prashantinfozion's profile prashantinfozion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.5.2
Component: Query Keywords:
Focuses: Cc:

Description (last modified by sabernhardt)

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.

Change History (2)

#1 @sabernhardt
19 months ago

  • Description modified (diff)

#2 @SergeyBiryukov
19 months ago

  • Component changed from General to Query
Note: See TracTickets for help on using tickets.