最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Unable to retrieve any child terms using get_terms

matteradmin9PV0评论

For some reason I'm not able to retrieve any child terms for the carabana_cat taxonomy. Here's what I've done so far:

$custom_terms = get_terms( 'carabana_Cat', array( 'hide_empty' => false, 'orderly' => 'description', 'child_of' => 28) );

What am I doing wrong here? There are lots of child terms for id=28 which aren't showing up.

For some reason I'm not able to retrieve any child terms for the carabana_cat taxonomy. Here's what I've done so far:

$custom_terms = get_terms( 'carabana_Cat', array( 'hide_empty' => false, 'orderly' => 'description', 'child_of' => 28) );

What am I doing wrong here? There are lots of child terms for id=28 which aren't showing up.

Share Improve this question edited Mar 21, 2019 at 15:46 Dave 2003 silver badges15 bronze badges asked Aug 24, 2016 at 16:42 Aaron McKaineAaron McKaine 31 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 0

Try relying on the new WP_Term_Query() class, here's an example per your code:

 // WP_Term_Query arguments
$args = array( 
                'taxonomy'  => 'carabana_Cat', 
                'hide_empty' => false, 
                'orderby' => 'description', 
                'child_of' => 28) 
                );

// The Term Query
$term_query = new WP_Term_Query( $args );

Taxonomy names are case–sensitive:

d( taxonomy_exists( 'post_tag' ) ); // true
d( taxonomy_exists( 'post_Tag' ) ); // false

You seem to have mismatch between taxonomy name and your code.

PS also orderly reather than orderby typo.

Post a comment

comment list (0)

  1. No comments so far