Custom post type and taxonomy problem
-
Hey guys,
I’ve added a People custom post type and am adding departments using custom taxonomies.
For the People page, I would like it to display a specific term from the taxonomy as a title and follow with the People posts that are related to this taxonomy term.
Then it should display the next taxonomy term with the People posts listed etc. repeating until end of the taxonomy term list.This code from the Codex displays the taxonomy terms no problem
$terms = get_terms("departments"); $count = count($terms); if ( $count > 0 ){ echo "<ul>"; foreach ( $terms as $term ) { echo "<li>" . $term->name . "</li>"; } echo "</ul>";
and this code displays what I need from the posts
$loop = new WP_Query(array('post_type' => 'people', 'posts_per_page' => 10, 'orderby' => 'menu_order', 'order' => 'ASC')); while ($loop->have_posts()) : $loop->the_post(); ?> <h2><a>"><?php the_title(); ?></a></h2> <?php if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it. ?><a>"><?php the_post_thumbnail(); ?></a><?php } the_excerpt(); endwhile;
So what’s the best way of accomplishing what I need? I’m certain that the post loop will have to nest inside the taxonomy loop so that the posts can be queried based upon the current taxonomy term but I’m unsure how to achieve this.
Thanks in advance.
- The topic ‘Custom post type and taxonomy problem’ is closed to new replies.