Opened 12 years ago
Closed 9 years ago
#21881 closed defect (bug) (fixed)
wp_list_categories show_option_all does not work for custom taxonomy
Reported by: | arkinex | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 4.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description
I am using wp_list_categories on a custom post type page to list the taxonomy values (categories). However if I include an All link it links by default to /blog/ and not /taxonomy/.
Attachments (5)
Change History (21)
#5
@
10 years ago
- Keywords needs-patch needs-unit-tests added
- Milestone changed from Awaiting Review to Future Release
A patch will move this along. Thanks for the report, arkinex.
#7
@
10 years ago
arkinex, thanks for the bug report :)
It looks like there's no general category page (i.e. /category by default) that would display all posts by all categories.
Since $posts_page is the right path for displaying all posts, isn't linking to the posts page the desired behavior here?
#8
@
10 years ago
- Keywords needs-testing added; needs-patch removed
Patch added, but it could use some unit tests (along with the rest of wp_list_categories()
. If the post_type
query var is populated, the returned URL will come from get_post_type_archive_link()
instead of get_permalink( get_option( 'page_for_posts' ) )
or home_url( '/' )
.
First patch, any and all feedback welcome :).
@
10 years ago
As get_query_var() can return arrays, only use get_post_type_archive_link() will receive a string
This ticket was mentioned in Slack in #core by stevegrunwell. View the logs.
10 years ago
@
10 years ago
Talking it through with Nacin, we realized that changing the "all" link based on context was the wrong behavior. Instead, if a post type is only used for one, non-built-in taxonomy, link to the archive for that post type (if it exists).
This ticket was mentioned in Slack in #core by stevegrunwell. View the logs.
10 years ago
#12
@
10 years ago
- Keywords needs-patch added
stevegrunwell - Thanks for working on this. The approach in the patch looks mostly good to me. The only change I'll suggest is that when a taxonomy is associated with more than one post type, we should still try to do something intelligent with it, even if it's just grabbing the first member of object_type
that has_archive
.
I wrote a few unit tests for the existing behavior in [31301]. Perhaps you could use them as a template for additional tests that describe the current bug. Off the top of my head, the cases seem like this: (a) more than one object_type
and the first one has_archive
; (b) more than one object_type
and the first one does *not* has_archive
; (c) none of the object_type
s has_archive
.
#13
@
10 years ago
- Keywords needs-patch removed
Hi,
As per @boonebgorges suggestion, I have updated the patch to handle all types of conditions as to check if more than one object_type and first one either has_archive enabled or disabled with continuing the check on further object types (post_type).
I used array_shift instead of normal indexing ($object_type[$i]) in the loop as the array obtained from taxonomy->object_type may start from any number as index instead of fixed number 0 depending on the post_types taxonomy has been registered with.
#14
@
10 years ago
- Keywords 4.3-early added; needs-unit-tests good-first-bug removed
hrishiv90 - Thanks for the patch. This is getting close. 21881.5.patch includes a unit test for the new behavior, and simplifies the logic of 4.patch a little (also accounting for the possibility that an object_type
might not be a valid post type).
#21881 was marked as a duplicate.