Make WordPress Core

Opened 14 years ago

Closed 7 years ago

Last modified 7 years ago

#13949 closed enhancement (wontfix)

Add a sprintf style argument to wp_list_categories() for title tag.

Reported by: mfields's profile mfields Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: needs-testing needs-unit-tests has-patch
Focuses: Cc:


By default, wp_list_categories() will use the value of $term->description for the title tag of every link that it generates. If the argument "use_desc_for_title" is set to false, it will produce a string like: "View all posts filed under $term->name". With the inclusion of custom post_types into core, it would be wonderful to have more control over this title. The best solution that I can think of is to add a sprintf style argument which will allow themes and plugins to provide a custom format. Something like:

'title_format' => 'View all tacos posted under %s.'

Attachments (4)

13949.diff (1.6 KB) - added by wonderboymusic 11 years ago.
16946.2.patch (1008 bytes) - added by Mte90 8 years ago.
refreshed patch for 4.6
13949.2.diff (1.1 KB) - added by Mte90 8 years ago.
sorry wrong patch, this is patch for wp 4.6
13949.3.diff (2.0 KB) - added by Mte90 8 years ago.
added docs

Download all attachments as: .zip

Change History (14)

#1 @nacin
13 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Seems fine to me.

#2 @wonderboymusic
11 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

Added a patch - not sure how important this one is. I'll let someone else decide if they need this in 3.7

#3 @nacin
11 years ago

13949.diff screws up the translation functions. Otherwise, good for commit.

#4 @chriscct7
9 years ago

  • Keywords needs-refresh added

8 years ago

refreshed patch for 4.6

8 years ago

sorry wrong patch, this is patch for wp 4.6

#5 @Mte90
8 years ago

  • Keywords needs-refresh removed

I updated the patch code without the title_format because now in the code is available title_li that have the same behaviour.
I have added only the feed_title that is missing in the actual version.

#6 @boonebgorges
8 years ago

  • Keywords needs-patch needs-unit-tests added; has-patch removed

Hi @Mte90 - Thanks for the patch. A few comments and requests:

  • We'll need documentation for the new parameter. See
  • Why are we calling it feed_title when it's used for the alt attribute? Is there an example of this usage elsewhere in WP?
  • You mentioned that title_li does the same thing as the proposed title_format, but I don't think that's true. 13949.diff proposes a sprintf-friendly string that is used for the link title attribute. I don't have strong feelings about whether this feature is necessary.
  • Ideally, we'd have unit tests demonstrating the sprintf() behavior. See tests/phpunit/tests/category/wpListCategories.php

8 years ago

added docs

#7 @Mte90
8 years ago

Hi @boonebgorges thanks for the help,

#8 @jorbin
8 years ago

  • Keywords has-patch added; needs-patch removed

This still needs some unit tests.

#9 @Mte90
7 years ago

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

Looking better at the code this feature is not required because today the feed parameter enable to insert a custom text and my patch was only changing the text in case of that value is not customized.
So this feature is already covered by WordPress :-)

#10 @netweb
7 years ago

  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.