Skip to content

Get Category ID from Category Name, or Category Slug

// From Name
$term = get_term_by( 'name', 'Category Name', 'category');
// From Slug 
$term = get_term_by( 'slug', 'category-slug', 'category');
 
echo $term->term_id;

Categories: .

Comment Feed

No Responses (yet)



Some HTML is OK

or, reply to this post via trackback.