Welcome Guest, Not a member yet? Register   Sign In
How to create categories and associate them with posts
#7

Quote:If you go to miosito.com/category/love
I show counting articles and articles

No, it doesn't. It gives a blank page.

If you just want the count of one category, you could do this:
PHP Code:
public function count_per_category($category=NULL)
{
 
$this->db
  
->select('slug_category, COUNT(id) as cat_count')
 
 ->from('posts');
 
 if ($category$this->db->where('slug_category',$category);
 
 $query $this->db
  
->group_by('slug_category')
 
 ->order_by('slug_category')
 
 ->get();
 
 return 
$query->result_array();


Now, the function is flexible. You can use it to get the count of all categories, or just one category.
Reply


Messages In This Thread
RE: How to create categories and associate them with posts - by Wouter60 - 09-16-2017, 05:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB