WordPress.org

Ready to get started?Download WordPress

Forums

How to list posts that share the current post's taxonomy term (2 posts)

  1. psnepsts
    Member
    Posted 2 years ago #

    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.

  2. keesiemeijer
    moderator
    Posted 2 years ago #

    Try it with this: http://pastebin.com/QwqjVkzx

Topic Closed

This topic has been closed to new replies.

About this Topic