WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 8 months ago

#17027 closed enhancement (duplicate)

Allow WP_Query to return just the count

Reported by: scribu Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords: needs-patch
Focuses: Cc:

Description

Currently, you can't ask just for the total number of posts for a certain query.

You have to execute that query and then retrieve the total using SQL_CALC_FOUND_ROWS.

Maybe a 'fields' => 'count' option would do it.

Example where this is needed in Core: #17019

Change History (1)

comment:1 wonderboymusic8 months ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

I refreshed the patch of #17019

Note: See TracTickets for help on using tickets.