The WP_Query::have_posts
takes into consideration just the current_post
and post_count
properties of the object ( see the Code Reference for more details ). And those are, in deed, empty in your var_dump
:
["posts"]=> array(0) { } ["post_count"]=> int(0) ["current_post"]=> int(-1)
So perhaps the query args are not correct and you are attempting to query something what can’t be found in the database.
You can try to run the MySQL query directly in the database to see whether it’s matching anything:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
WHERE 1=1
AND wp_posts.ID IN
(12501,12502,12503,12506,12510,12513,12528,12529,12536,12557,12558,
12561,12565,12575,12576,12578,12587,12601,12602,12603,12604)
AND ( ( wp_postmeta.meta_key = '_customer_user' AND wp_postmeta.meta_value="10" ) )
AND wp_posts.post_type="shop_order"
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC
LIMIT 0, 20
I would specifically checked whether the post IDs are correct and whether they have the necessary post_meta with matching meta_value.