1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
		<ul>	    
<?php
			global $wpdb;
			$res = $wpdb->get_results("SELECT t.term_id, t.name, t.slug, COUNT(a.id)
							FROM
							      wp_terms t
							LEFT JOIN
							      wp_wpa_auctions a
							ON
							      t.name  = a.terms
							WHERE
							      DATE(date_end) >= DATE(CURDATE())
							GROUP BY
							      t.name
							ORDER BY
							      t.name ASC;");


			foreach ($res as $rs) {

				$counter = COUNT(a.id);
				echo '<li><a href="';
				echo bloginfo('url');
				echo '/auction-category';
				echo '?link=';
				echo $rs->name;
				echo '">';
				echo $rs->name;
				echo '(' . $counter . ')';
				echo '</a></li>';
			}
			?>
		</ul>