0

This is my query, it's so simple (the query is generated by canvas plugin) ps: the $page has correct value

$query_var = [
'post_type' => 'new',
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => 3
];

$query = new WP_Query($query_var);

This is a picture of the generated array for WP_Query enter image description here

when i press the load more button, it shows me duplicated posts randomly, although the posts aren't duplicated in the db

This is the generated SQL query

SELECT SQL_CALC_FOUND_ROWS  eepir_posts.ID FROM eepir_posts  INNER JOIN eepir_postmeta ON ( eepir_posts.ID = eepir_postmeta.post_id ) WHERE 1=1  AND eepir_posts.ID NOT IN (2405,101648,101576,101582,101586,101598,123796,107475,107695,123304,102506,102126,102034,102573,119231,123818,103813,85842,86197,86087,126258,126266,111468,111492,97183,124539,99686,99667,99642,99628) AND ( \n  ( eepir_postmeta.meta_key = 'is_english' AND eepir_postmeta.meta_value != '1' )\n) AND eepir_posts.post_type = 'new' AND ((eepir_posts.post_status = 'publish')) GROUP BY eepir_posts.ID ORDER BY eepir_posts.post_date DESC LIMIT 3, 3

i notic that when i change the orderby arg to something else, like this

$query_var = [
'post_type' => 'new',
'orderby' => 'ID',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => 3,
];

it works fine, or if i didn't use the orderby argument, it also works. how can i fix this? Thank you

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.