bump, I’d be interested in this also. I’ve been poking around the category.functions.php file and I can see the reason that we’re not able to use any kind of simple variable is because the function does a single DB call and outputs all of the HTML by the time it even gets into our hands… Simply speaking this isn’t a loop at all, just a very elaborate database query.
I’ve been able to bring out a post count in plain HTML but for my application I need to figure out how to get a PHP variable in my hands so that I can split my output into two sections a TOP and BOTTOM output (if that makes sense).
If your simply looking for an HTML output you can create a new function in “wpsc-includes/category.functions.php”:
/**
* wpsc print category count function
* places the shortcode for the category count
*/
function wpsc_print_category_count(){
echo "[wpsc_print_category_count]";
}
On line 266-ish add a key to the foreach:
foreach((array)$category_data as $count => $category_row) {
Add the shortcode and replacement value into the output on line 362-ish:
// get the list of products associated with this category.
$tags_to_replace = array('[wpsc_category_name]',
'[wpsc_category_description]',
'[wpsc_category_url]',
'[wpsc_category_id]',
'[wpsc_category_classes]',
'[wpsc_category_image]',
'[wpsc_subcategory]',
'[wpsc_category_products_count]',
'[wpsc_print_category_count]');
$content_to_place = array(
esc_html($category_row->name),
$category_description,
esc_url( get_term_link( $category_row->slug, 'wpsc_product_category' ) ),
$category_row->term_id,
$category_classes,
$category_image_html,
$sub_categories,
$category_count_html,
$count);
Then you could just call it using something like:
<?php wpsc_print_category_count(); ?>