Support » Fixing WordPress » How to list posts that share the current post's taxonomy term

  • I’ve created a custom post type called “courses” and have a taxonomy to differentiate between ‘course_types.’ I’m trying to create a single-courses.php page that will populate a side navigation list with posts that share the same ‘course_type’ (taxonomy term). So far I’ve only had success running a hard query to generate the list:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    Here the term I’m looking for is “upgrade” and I’ve had to hard code it in here. Is there some way for me to:
    1 – get the term associated with the current post
    2 – store it in a variable, and
    3 – pop that into the query above

    … so that, if I’m on a post that is an ‘upgrade’ course we create a list of links to all courses that share that type? And, of course, if we’re on a course of a different type, say, ‘mandatory’, that list would populate with all of the mandatory courses.

    Many thanks.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to list posts that share the current post's taxonomy term’ is closed to new replies.