📜  搜索分类 wordpress 查询 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:43.456000             🧑  作者: Mango

代码示例1
// 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 "";
 }

}

// sample
get_tax_by_search('Foo');