Opened 9 years ago
Last modified 6 years ago
#32789 new enhancement
Abstract get_category_by_path into get_term_by_path
Reported by: | sc0ttkclark | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | needs-patch needs-unit-tests |
Focuses: | Cc: |
Description
Having a function like get_term_by_path
would be great as currently you have to fork the get_category_by_path
function on your own to get a term by path for any other custom taxonomy.
Would there be any opposition to a patch for this? The abstracted function wouldn't house the _make_cat_compat
usage, which would remain in the backwards compatible get_category_by_path
function after checking to see if $category is not null.
Change History (5)
#3
@
9 years ago
I have noticed that get_category_by_path doesn't work well with category-hierarchy, where the same slug exists with different parent.
Maybe fix this new generic term-method to handle this? And make get_category_by_path() call the new method?
Could be nice if the following was possible:
/men/shoes/
/women/shoes/
Based on
get_category_by_path
:I added $taxonomy as a required second parameter.
I also fixed a few things, one was
@return
was not properly reporting WP_Error as a possible return type, others were formatting or variable names. The get_terms empty check did not have an elseif check foris_wp_error( $terms )
so that's been put in place as well.