To retrieve only the top-level terms of a taxonomy, you can add the 'parent' parameter to the $cat_args array and set it to 0. Here's an updated version of your code:

$cat_args = array(
   'meta_key' => 'qq_cat_piority',
   'orderby' => 'meta_value_num',
   'order' => 'ASC',
   'hide_empty' => false,
   'parent' => 0, // Only retrieve top-level terms
);

$qqcpategories = get_terms( 'qqcpat', $cat_args );

By setting the 'parent' parameter to 0, you are telling the get_terms function to only retrieve terms that have no parent. This will give you only the top-level terms of the 'qqcpat' taxonomy

$cat_args = array meta_key = qq_cat_piority orderby = meta_value_num order = ASC hide_empty = false; $qqcpategories = get_terms qqcpat $cat_args ;i want only the top level of this taxonomy n

原文地址: https://www.cveoy.top/t/topic/iBdp 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录