据我所知,您需要在函数中编写以下函数。使用下面的函数检查术语是否有post
function check_term_posts($tax_slug, $term_id) {
$args = array(
\'post_type\' => \'post\',
\'status\' => \'publish\',
\'tax_query\' => array(
array(
\'taxonomy\' => spanishcategory,
\'field\' => \'term_id\',
\'terms\' => 169
)
)
);
$term_query = new WP_Query($args);
$term_posts_count = $term_query->found_posts;
if( $term_posts_count>0 ){
return true;// You can code here to echo name of category
} else {
return false;
}
}
请告诉我这是否可以解决您的错误或需要任何帮助?