Skip to content

found_posts on new PostQuery() #1973

@Grafikart

Description

@Grafikart

Is your feature request related to a problem? Please describe.

There is no way to get the total number of post from the PostQuery object which forces users to write things like this :

$query = new WP_Query([
    'cat'            => $category->id,
    'post__not_in'   => get_option('sticky_posts'),
    'posts_per_page' => $context['offset']
]);
$context['posts'] = new PostQuery($query);
$context['found'] = $query->found_posts;

Describe the solution you’d like

A method (total() or found()) on PostQuery to get the total number of post found.

Questions

Is there a reason why this feature is not implemented ? I may be able to submit a PR to implement this myself but I want to know if there was a reason for not including this in the PostQuery class.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions