#13949 closed enhancement (wontfix)
Add a sprintf style argument to wp_list_categories() for title tag.
Reported by: | mfields | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | needs-testing needs-unit-tests has-patch |
Focuses: | Cc: |
Description
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)
Change History (14)
#1
@
14 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
#2
@
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
@
11 years ago
13949.diff screws up the translation functions. Otherwise, good for commit.
#5
@
9 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
@
9 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 https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/
- Why are we calling it
feed_title
when it's used for thealt
attribute? Is there an example of this usage elsewhere in WP? - You mentioned that
title_li
does the same thing as the proposedtitle_format
, but I don't think that's true. 13949.diff proposes asprintf
-friendly string that is used for the linktitle
attribute. I don't have strong feelings about whether this feature is necessary. - Ideally, we'd have unit tests demonstrating the
sprintf()
behavior. Seetests/phpunit/tests/category/wpListCategories.php
#7
@
9 years ago
Hi @boonebgorges thanks for the help,
- the last patch contain the docs
- I choosen that name after saw the name of feed_* parameters and of title_li
- Now that code have a filter in this place https://github.com/WordPress/WordPress/blob/master/wp-includes/class-walker-category.php#L121 before there was an
else
that not exist anymore - I can try to do an unit tests for this patch
#9
@
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 :-)
Seems fine to me.