Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#13907 closed defect (bug) (invalid)

get_categories with custom taxonomy ignores "depth"

Reported by: yeswework Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: close dev-feedback
Focuses: Cc:


in the following query:

$books = get_categories('taxonomy=book_title&depth=1');

depth=1 gets ignored, and all levels of the taxonomy are returned.

wp_list_categories works fine, on the other hand.

I'm assuming this is a bug...

Change History (4)

#1 @ocean90
8 years ago

  • Component changed from General to Taxonomy
  • Keywords dev-feedback added
  • Milestone changed from 3.0 to Future Release
  • Version set to 3.0

I can reproduce it with categories too, in 2.9 too. So not a regression.
Is it intentionally?

#2 @ocean90
8 years ago

  • Keywords close added

wp_list_categories() supports the depth arg, see here
get_categories() uses get_terms() and get_terms() doesn't support the depth arg.

#3 @nacin
8 years ago

  • Milestone Future Release deleted
  • Resolution set to invalid
  • Status changed from new to closed

get_categories() does not take a depth argument.

As pointed out by filosofo, you can use wp_list_categories() with echo = 0.

#4 @filosofo
8 years ago

ocean90 pointed that out, but I agree. :-)

Note: See TracTickets for help on using tickets.