sitecrafting / conifer

:evergreen_tree: A powerful WordPress library plugin for OO development
https://www.coniferplug.in
MIT License
18 stars 2 forks source link

Term counts for custom statuses #115

Closed acobster closed 4 years ago

acobster commented 5 years ago

Expected behavior

I want to be able to register custom statuses and have them count toward term counts. I want this to work Post::get_all_grouped_by_term().

Actual behavior

Honoring custom statuses is currently very difficult. You need to completely override get_all_grouped_by_term() to get it to correctly take custom statuses into account.

Steps to reproduce behavior

Declare a custom status, e.g. archived, and then call MyCustomPost::get_all_grouped_by_term(['post_status' => 'archived']); note that posts in the custom status are not included. Furthermore, even if you pass a custom update_count_callback to register_taxonomy(), in some cases the count may still be incorrect because the underlying term query is based on hide_empty, which checks the denormalized term count stored in the database instead of the dynamic result of Timber's $term->posts() method.

What version of WordPress/PHP/Timber/Conifer are you using?

This issue exists in every Conifer version since get_all_grouped_by_term() was introduced.

How did you install Conifer? (for example, via git clone, GitHub zip download, Composer/Packagist?)

This issue exists regardless of installation method.