I have a CPT registered that is called lessons with a custom taxonomy (category) that is called courses. I want the /courses page (archive-courses.php?) to display the individual courses (i.e. "online marketing", "paid advertising") and not the individual posts (lessons).

Would this mean I'd just customize the loop, or a complete custom WP_Query?


If you'd like to list the individual courses, i.e. the taxonomy terms, you'd use neither WP_Query nor the WP standard Loop.

Instead, make use of the get_terms function to retrieve the courses. It returns an array of term objects (if the taxonomy does exist and has terms matching the function arguments). Iterate over that and do something with it, such as displaying a list of links to the lessons:

$courses = get_terms( 'courses' );

if ( $courses ) {
    echo '<ul class="course-list">';

    foreach ( $courses as $course ) {

        echo '<li>' .
            '<a href="/courses/' . $course->slug . '" ' .
                'title="' . sprintf( 'View lessons of %s', $course->name ) . '">' .
                    $course->name .
            '</a>' .


    echo '</ul>';

Its look like you calling Custom Post (archive-courses.php) not taxonomy. Try this taxonomy-courses.php also have a look Custom_Taxonomies_display

  • That would work for me if the courses page was a taxonomy archive page, it's not though. It is the archive of my custom post type. – Zach Russell Apr 6 '13 at 22:19
  • yes! you are right. my mistake! – Muhammad Furqan Apr 6 '13 at 22:25
  • I appreciate the feedback though! – Zach Russell Apr 6 '13 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.