How can I filter custom post type taxonomy results?
-
I’m sure that this has been covered but I can’t find the solution anywhere. Please can somebody help?
I have a custom post type of Courses, which has 2 taxonomies: Course Subject and Course Location.
I have set up a page entitled Courses Overview, with some helpful intro text. Beneath this text I have displayed links to the Course Locations:
<?php $args = array ( 'taxonomy' => 'course_location', 'title_li' => '' ) ; ?> <?php wp_list_categories( $args ); ?>
Each Course Subject is displayed in a separate table on the taxonomy-course_location.php template.
Example:
The user clicks London
(on mysite.com/courses-overview)And is shown 3 tables: Design; Photography; Drawing
(on mysite.com/course-location/london)Everything is working correctly except I can’t work out how to filter the results. So, using the example above, The Design table shows ALL of the design courses, not just the ones in London.
How do I restrict the results to only be for the current Location?
This is my code for the taxonomy-course_location.php template:
<?php $term = $wp_query->queried_object; ?> <h1>Courses in: <?php echo $term->name ; ?></h1> <?php $args = array( 'post_type' => 'courses', 'course_subject' => 'design', 'posts_per_page' => 200 ); $currentDesignCourses = new WP_Query( $args ); ?> <table> ... stuff ... </table>
- The topic ‘How can I filter custom post type taxonomy results?’ is closed to new replies.