📅  最后修改于: 2022-03-11 14:53:43.456000             🧑  作者: Mango
// We get a list taxonomies on the search box
function get_tax_by_search($search_text){
$args = array(
'taxonomy' => array( 'my_tax' ), // taxonomy name
'orderby' => 'id',
'order' => 'ASC',
'hide_empty' => true,
'fields' => 'all',
'name__like' => $search_text
);
$terms = get_terms( $args );
$count = count($terms);
if($count > 0){
echo "";
foreach ($terms as $term) {
echo "- ".$term->name."
";
}
echo "
";
}
}
// sample
get_tax_by_search('Foo');