@吉尔,你在评论中的解决方案似乎很好!我只是修改了一小部分,以确保在执行时不会出现PHP警告。
$w_year = $_GET[\'w_year\'];
$catid = \'\';
$taxonomies = get_taxonomies();
foreach ( $taxonomies as $taxonomy ) {
if ( $term_object = get_term_by( \'slug\', $w_year , $taxonomy ) ) {
if ( !empty($term_object->term_id) ) {
$catid = $term_object->term_id;
break;
}
}
}