in get_the_category_list(), filter categories before constructing list
|Reported by:||KevinB||Owned by:||anonymous|
|Severity:||normal||Keywords:||category filter has-patch tested|
The template function get_the_category_list returns a concatenated string of category links for an individual post. The only filtering available is on the full concatenated sting, via 'the_category' hook.
Since filtering the category array directly is greatly preferable for most uses, please consider adding the attached patch, or something like it.
Whatever hook is added should somehow indicate the data context - in this case for display. In filtering post categories, there is the potential for non-display situations in which the actual post categories must be maintained even though the display filtering hides some from the current user. What we should not do is apply a single filter inside get_the_category or wp_get_object_terms, since themes and plugins may already call those functions for multiple data contexts.
I had considered calling the new hook 'get_the_category_for_list'. Instead I'm suggesting a more generic 'get_the_category' hook, passing context as the second argument. That would leave the API consistent for possible future use in filtering other contexts.
Change History (13)
- Keywords changed from category template filter to category, template, filter