Support » Plugins and Hacks » Best method for post count per category

  • Resolved lonewolfonline


    I’m having a little trouble obtaining a post count for a given category that includes the post count of all child categories. My current code executes a sql query for each parent, then each sub category and sub sub category and so on. Lots of sql!

    Is there an easy way to do this? I’m developing for 2.3 only.

    example (I am after the count for each item)

    Parent 1 (5)
    – Child 1 (1)
    – Child 2 (1)
    – – Sub Child 1 (1)
    – Child 3 (2)

    Sub Child 1 is easy, just select the count for that id, child’s – one sql for each (but we only want to count unique, ie don’t count a post in child 1 twice if its also in child 3) Then it gets complicated for another level.
    To me this is excessive, especially since performance is important to me (I have a blog with 200+ categories all nested together)

    Any help appreciated



Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Best method for post count per category’ is closed to new replies.