This is a known problem. Check the WPBug page on the wiki, http://wiki.wordpress.org/WPBugs. Some people have came up with a workaround, but this function is no longer working, and rumor has it, no longer supported.
That link does not reveal much :-). I would appreciate more info on this subject too – presumably there is a way of retreiving category (‘s) for each post.
Andrew
The link ended up with a period in it and should be http://wiki.wordpress.org/WPBugs – Look down the page for 1.2 frequent problems & bugs. This is one of them.
Previous forum entries on this at http://wordpress.org/support/index.php?action=vthread&forum=3&topic=5757&page=0
http://wordpress.org/support/3/6368
http://wordpress.org/support/3/5287
And if you search on the function name, I think you’ll find other threads.
Supposedly there might be a 1.2.1 branch, and this might be fixed in it. And a suggestion has been made to use get_the_category instead.
Thread Starter
Anonymous
I came up with a short workaround for this bug bear in mind I don’t understand the whole wordpress system so if my code is sloppy don’t get on my case. just put the following code in your template-functions file:
function this_cat_id($seperator = ”) {
$categories = get_the_category();
$i = 0;
foreach ($categories as $category) {
$category->cat_name = stripslashes($category->cat_name);
if (0 < $i) echo $seperator . ‘ ‘;
$output = $category->category_id;
++$i;
}
return($output);
}
Thread Starter
Anonymous
I’ve looked at that code provided above and I’d say it’s doing too much work… my solution is:
(insert at end of wp-includes/template-functions-category.php)
function print_cat_id()
{
$categories = get_the_category();
foreach ($categories as $category)
{
echo $category->category_id;
break;
}
}
This prints the first category (as stored in the WP database). I figure if you want it to print a list of category IDs it’s a different question, but this is what works as a replacement for the_category_id imho
— Karan
Thread Starter
Anonymous
dunno why that took so long for someone to post.