OK, so I asked this earlier and no one had any answer for me. I have a CPT for FAQs. FAQs are separated into 'categories.' I need the name of the 'category' then a every post within that 'category.'
Example:
Category 1
Title of Post 1 within Category 1
Content of Post 1 within Category 1Title of Post 2 within Category 1
Content of Post 2 within Category 1Category 2
Title of Post 1 within Category 2
Content of Post 1 within Category 2Title of Post 2 within Category 2
Content of Post 2 within Category 2
The code that I now have is:
<?// for a given post type, return all except 'uncategorized'
$post_type = 'faq';
$tax = 'category';
$tax_terms = get_terms($tax, array('orderby' => 'id', 'order' => 'ASC', 'exclude' => '1'));
if ($tax_terms) {
foreach ($tax_terms as $tax_term) {
$args = array(
'post_type' => $post_type,
"$tax" => $tax_term->slug,
'post_status' => 'publish',
'posts_per_page' => - 1,
'orderby' => 'title',
'order' => 'ASC',
'caller_get_posts' => 1
); // END $args
$my_query = null;
$my_query = new WP_Query($args);
if ($my_query->have_posts()) {
echo '<div class="aro"><div class="wrap"><h2>' . $tax_term->name . '</h2></div><div class="details"><div class="wrap">';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="info">
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
</div>
<?php
endwhile; } // END if have_posts loop
echo '</div></div></div>'; // Close 'details', 'wrap', & 'aro' DIVs
wp_reset_query(); } // END foreach $tax_terms
} // END if $tax_terms
?>
This code does list every 'category' individually, which I do want. However, every post within FAQs is listed under every 'category,' which is not what I want. Any ideas what I'm doing wrong?