Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter gnucco

    (@gnucco)

    Hi, finally I’ve found a solution (it could not be the best, but it seems to work).
    First I created a category template for each category (let’s say I have 4 categories), copying the file index.php of my theme 4 times and renaming them category-XX.php, where XX is the ID category. Then I edited those 4 files adding at the beginning of files the following code, taken and adapted from http://www.web-templates.nu/2008/09/21/get_category_count/ :

    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);
    	}
    }
    
    <?php $max_page=floor(wt_get_category_count(XX)/5); ?>

    where again XX is the ID category and 5 is the number of posts per page.

    Now everytime I click on a category $max_page variable is computed and vavigation should work as normal.

    bye

Viewing 1 replies (of 1 total)