Opened 15 years ago
Closed 15 years ago
#19938 closed defect (bug) (wontfix)
Setting fields as ids or id=>parent does not setup post/count properties
| Reported by: | ejdanderson | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | 3.0 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
This may be intentional. But consider the following
$query = new WP_Query(array('fields' => 'ids'));
if ($query->have_posts() || $query->post_count || $query->post || $query->current_post != -1) {
//do something
}
The code that sets all these properties is never fired when getting the posts, regardless of what is returned.
The same happens for array('fields' => 'id=>parent');
Is this intentional? I can see reasons on both sides of this.
Perhaps at the very least, the 'the_posts' filter needs to be run when these arguments are passed
Change History (1)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
It is intentional, to prevent backwards compatibility woes.
For example, calling 'the_posts' filter would probably break a lot of plugins which expect objects, not integers.
Also, instead of
$query->have_posts(), just use!empty( $query->posts ).