Hi,
I've developed a couple of widgets that I'm now updating with increased Conditional functionality. I've included the option to specify "Post(s) in Category(-ies)". The way it works is that it allows people to identify conditonal categories based on comma separated ID(s) which in turn displays the widget in posts belonging to the category (or categories) as well as on the respective category archive pages.
The problem is now that Wordpress in 2.5 has excluded the Category ID from the list view in the admin section so that they only see slug and title. As I'm using the in_category($ID) function, I'm asking the users to put the category IDs in the input area. I'm aware that you can see the category ID through mousover on the list, but that is not user friendly.
Is there a function where I based on category slug or title can extract the ID easily? My code looks like this at the moment:
case "post_in_category":
$PiC = explode(",",$slug);
$InCategory = false;
foreach($PiC as $CategoryID) {
if(is_single() && in_category($CategoryID)){
$InCategory = true;
}
elseif (is_category($CategoryID)) {
$InCategory = true;
}
}
Never mind the $slug name (it is a variable name for ID/slug/title) and in this specific case I'm just asking for the ID.
I guess I'll have to get an array of slugs instead and then convert them to an array of IDs in order to process using the in_category function.
Daiko