#21733 closed defect (bug) (duplicate)
WP_Query::have_posts should work when "fields" is set
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Query | Keywords: | has-patch |
| Focuses: | Cc: |
Description
If you set fields to ids or id=>parent in a WP_Query instance, WP_Query::post_count does not get set, so WP_Query::have_posts() returns false. It shouldn't.
To test:
$q = new WP_Query( array( 'posts_per_page' => -1 )); var_dump( $q->have_posts() ); $q = new WP_Query( array( 'posts_per_page' => -1, 'fields' => 'ids' ) ); var_dump( $q->have_posts() ); exit();
You get this for free just by setting WP_Query::post_count - patch attached
Attachments (1)
Change History (3)
Note: See
TracTickets for help on using
tickets.
dupe of #21147