How to Get Taxonomy ID by Slug in WordPress
To get the taxonomy ID by slug in WordPress, you can use the 'get_term_by()' function. Here is an example code snippet:
$term = get_term_by('slug', 'your-taxonomy-slug', 'your-taxonomy-name');
if ($term) {
$term_id = $term->term_id;
}
Replace 'your-taxonomy-slug' and 'your-taxonomy-name' with the actual slug and name of your taxonomy. The function will return the term object if a matching term is found, and you can access the taxonomy ID by accessing the 'term_id' property.
原文地址: https://www.cveoy.top/t/topic/oo7s 著作权归作者所有。请勿转载和采集!