I have a bilangual page where posts are sorted by categories and subcategories. When i check hoew many posts are actually displayed on a category page I get 312 in both languages. When I check the admin table for that same category it shows 291 posts for one language and 301 posts for the other language. Also when I count the posts with php in the template archive.php as shown below I get 291 / 301 instead of 312 posts.
$current_cat_id = get_query_var('cat');
$category = get_category($current_cat_id);
$count = $category->category_count;
What am I missing? Any suggestions / pointers appreciated.
UPDATE: On this page http://www.web-templates.nu/2008/09/21/get_category_count/index.html I found a function titled "get_category_count" and after placing it in functions.php and calling it with the category slug it first seemed to give the correct results. But the results actually still differ from what i see in the admin columns when filtering for the same category.
function wt_get_category_count($input = '') {
global $wpdb;
if($input == '')
{
$category = get_the_category();
return $category[0]->category_count;
}
elseif(is_numeric($input))
{
$SQL = "SELECT $wpdb->term_taxonomy.count FROM $wpdb->terms, $wpdb->term_taxonomy WHERE $wpdb->terms.term_id=$wpdb->term_taxonomy.term_id AND $wpdb->term_taxonomy.term_id=$input";
return $wpdb->get_var($SQL);
}
else
{
$SQL = "SELECT $wpdb->term_taxonomy.count FROM $wpdb->terms, $wpdb->term_taxonomy WHERE $wpdb->terms.term_id=$wpdb->term_taxonomy.term_id AND $wpdb->terms.slug='$input'";
return $wpdb->get_var($SQL);
}
}
What am i kissing? Thanks!!