Skip to content

Instantly share code, notes, and snippets.

@aaronmcadam
Created May 13, 2010 00:20
Show Gist options
  • Save aaronmcadam/399315 to your computer and use it in GitHub Desktop.
Save aaronmcadam/399315 to your computer and use it in GitHub Desktop.
Expression Engine Number of posts under Categories
{!--
This script is useful for grabbing the number of entries under a category
--}
{exp:weblog:categories weblog="faq" style="nested" show_empty="yes"}
<h2>{category_name}</h2>
{exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count FROM exp_category_posts WHERE exp_category_posts.cat_id = {category_id}"}
<h4>{post_count} Question(s)</h4>
{/exp:query}
{exp:weblog:entries weblog="faq" disable="member_data|trackbacks" paginate="top" category="{category_id}"}
<h3><span class="question">Q.</span> {title}</h3>
<a href="#" title="Show Answer" class="show">Show Answer</a>
<div class="answer">{faq_answer}</div>
{/exp:weblog:entries}
{/exp:weblog:categories}
@aaronmcadam
Copy link
Author

This script is useful for grabbing the number of entries under a category

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment