Counting post and displaying result
-
Hi, I have the below code that counts posts from categories and then performs and echoes a sum. This is working fine except that it affect the posts that are displayed on the page. I guess this is because I’m using “query_posts”. Is there a way of getting just the post count without changing the posts on the page? I’ve tried changing “query_posts” to “count_posts”. But it didn’t work. Any help would be great.
<?php //melbourne postive $posts = query_posts(array('category__and' => array(6,25))); $melbpos = count($posts); ?> <?php //melbourne negative $posts = query_posts(array('category__and' => array(10,25))); $melbneg = count($posts); ?> <div style="color:#0F6;"><img src="teamImages/Melbourne.png" width="48" height="31" alt="Melbourne" />Melbourne <?php echo ($melbpos - $melbneg); ?> </div>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Counting post and displaying result’ is closed to new replies.