Skip to content

WP_Query row counts can be incorrect if query is filtered (seen in bbPress) #341

@rmc47

Description

@rmc47

Currently,

if( ! empty( $found_rows ) )
performs a COUNT() query to find the number of rows that would be returned if $limits did not apply.

However, if the posts_request filter causes the query to be changed, this row count may be invalid. This is the case in bbPress, where the _bbp_has_replies_where filter alters the WHERE clause to include the original topic as well as its replies in a single query.

Instead, we could perform the row count on the query after any filters have been applied if possible.

Incoming PR to do that, but it's a little scary...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions