Get Category ID From Category Name Function
10 Août 2013, Posted by in// Function to retrieve category ID, given name - http://www.jacobward.co.uk
function
get_category_id(
$category_name
) {
$term
= get_term_by(
'name'
,
$category_name
,
'category'
);
return
$term
->term_id;
}
// Assign category ID of 'Category Name' to $category_id variable
$category_id
= get_category_id(
'Category Name'
);