I have a loop inside a shortcode to display the list of posts for each category (schedule-day) in a custom post type (schedule).
The first category lists the posts in said category just fine, but the second category lists posts from both the first and second category.
Anyone experienced this issue before?
$terms = get_terms('schedule-day', 'hide_empty=1&orderby=name&order=ASC');
if(!empty($terms)) :
$verytop = '<div class="tabs"><ul>';
foreach($terms as $term) :
$term_name = $term->slug;
$args = array( 'post_type' => 'schedule', 'posts_per_page' => -1, 'schedule-day' => $term_name);
$query = new WP_Query( $args );
$top .= '<li><a href="#' . $term->slug . '">'.$term->name.'</a></li>';
$close = '</ul>';
if($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
$next = '<div id="'.$term->slug.'" class="itinerary">';
$middle .= '<div class="schedule-item '.$term->slug.'" title="'.$term->slug.'"><div class="schedule_content"><h3>'. get_the_title() . '</h3>' . get_the_content() . '</div></div>';
$nexter = '</div>';
endwhile; endif;
wp_reset_postdata();
$fish .= $next.$middle.$nexter;
endforeach;
$verybottom = '</div>';
return $verytop.$top.$close.$fish.$verybottom;
endif;
register_taxonomy
: Name should only contain lowercase letters and the underscore character, and not be more than 32 characters long – Milo Sep 23 '14 at 0:16