Ticket #9719 (reopened feature request)

Opened 3 years ago

Last modified 3 years ago

Please : a filter for $category object in get_the_category_list()

Reported by: michelwppi Owned by: anonymous
Priority: normal Milestone: Future Release
Component: Template Version: 2.8
Severity: minor Keywords: needs-patch
Cc: michelwppi

Description

To offer for one post more flexibility in how to display the names of categories in the_category() or in get_the_category_list() -file category-template line 166 - , is it possible to add a filter as the filter existing in wp_list_categories() . Useful to replace cat name by instance by image (iphone compatible theme) or to add translation in bilingual or multilingual theme (by instance with xili-language plugin) without re-creating specific function.

As in classes.php (line 1328), I suggest this modif with a filter named post_list_cats for the start of two loops present in get_the_category_list() (line 187 et 209)

foreach ( $categories as $category ) {
$cat_name = attr( $category->name);
$cat_name = apply_filters( 'post_list_cats', $cat_name, $category );

and inside the two loops, $category->cat_name replaced by $cat_name

with this filter it will be more coherent to treate cat list in one post or in sidebar for all posts

Many thanks

Change History

  • Status changed from new to closed
  • Resolution set to duplicate

there are a ticket or two in the 2.8 milestone already, that ask for the category list to be filtered, raw, before it gets turned into html. closing this as dup of those.

please reopen if you had something else in mind, though.

  • Status changed from closed to reopened
  • Resolution duplicate deleted

What are the ticket number talking about this subject ? Thanks

  • Milestone set to 2.8

things like #8704

please re-close as dup if it does the trick

in trac #8704 the proposed filter is placed upstream and will it be able to place an image url in place of a simple category name? the hook 8704 while large impact in what I propose, only the category (terms) in question. Is my english understandable ?

  • Cc michelwppi added
  • Summary changed from Please : a filter for $category name in get_the_category_list() to Please : a filter for $category object in get_the_category_list()

this ticket #9227 is much more relevant and adapted to the desired functional. Even if wp_list_categories(), a filter exists for each three parts of one element (name, link, and description). Here, just with adding a line like below, the potentialities of adaption are huge :

As in classes.php (line 1328), I suggest this adapted modif with a filter named post_list_cats for the start of two loops present in get_the_category_list() (line 187 et 209)

foreach ( $categories as $category ) {
$category = apply_filters( 'post_list_cats', $category);

If, as asked in the cited trac, the echo (display) is added in the function get_the_category_list() (with modif inside the_category), a second param 'echo' can be passed in this filter.

Hope this modif will be implemented soon, to built easy plug and play kit to transform automatically a well made theme in a theme for iPhone or a multilingual theme (without coding by the bloger).

  • Keywords needs-patch added
  • Priority changed from high to normal
  • Component changed from General to Template
  • Severity changed from normal to minor

#8704 got fixed. Might we want to close this as fixed along with it?

  • Milestone changed from 2.8 to 2.9

Punting per discussion during the WP meet-up...

  • Milestone changed from 2.9 to Future Release
Note: See TracTickets for help on using tickets.