Could someone please help me with this. I’m trying to show a list of questions and answers within each category. I have it working for the most part, but I can’t figure out how to group the questions and answers within the categories.
For example,
I’m getting:
Career Opportunities
question
answer
General Info
question
answer
General Info
question
answer
I would like to get:
Career Opportunities
question
answer
General Info
question
answer
question
answer
Here’s the code I’ve tried:
<h3 class="title">Frequently Asked Questions</h3>
{exp:channel:categories channel="faq" orderby="date" sort="desc" disable="categories|member_data|trackbacks"}
{exp:query sql="SELECT cat_id, group_id, cat_name, cat_url_title FROM exp_categories WHERE cat_url_title = '{category_url_title}'"}
{exp:channel:entries channel="faq" category="{cat_id}"}
<h4>{category_name}</h4>
<p> <a href="http://{title_permalink=customer-service/faq-details}"><b>{faq_question}</b></a><br />
{faq_answer}<br />
<br />
{/exp:channel:entries}<br />
<br />
{/exp:query} <br />
{/exp:channel:categories}</p>
<p> <br>and also
<h3 class="title">Frequently Asked Questions</h3>
{exp:channel:categories channel="faq" status="open" style="linear" show_empty="no"}
{exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count, field_id_127, field_id_128, exp_categories.cat_id FROM exp_category_posts
INNER JOIN exp_channel_data USING(entry_id)
INNER JOIN exp_categories USING(cat_id)
WHERE exp_category_posts.cat_id = {category_id} "}
<h4>{category_name} ({post_count})</h4>
<p> <a href="http://{path=%27/customer-service/%27}" class="current"><b>{field_id_127}</b></a><br />
{field_id_128}</p>
<p> {/exp:query}</p>
<p> {/exp:channel:categories}