WordPress.org

Ready to get started?Download WordPress

Forums

Get Posts with Custom Taxonomy (2 posts)

  1. nrutman
    Member
    Posted 3 years ago #

    So I'm using custom types & taxonomies on my site (great features!).

    The problem I'm having is that I'm trying to get a list of posts with a certain term. I have a taxonomy-NAME.php file for the specific taxonomy, and everything is working fine except have_posts() always returns FALSE.

    So then I think that maybe I need to manually query the posts with that term. According to the docs (bottom of this page) it looks like I should be able to do this with query_posts(), but when I use that syntax I get back all the posts -- whether they have my term or not.

    For clarity, here's what I'm appending onto the query array:

    get_query_var('taxonomy') => get_query_var('term')

    ...and I've double-checked: it's pulling in the correct taxonomy and term name for the page. But now it returns all of the posts.

    So what's the deal? How do you get a set of posts with a specific taxonomy term in them?

    Any help would be appreciated...I'm pulling my hair out.
    -Nate

  2. Acts7
    Member
    Posted 3 years ago #

    UGG Couldn't get it to post the code here properly.
    I posted the code on my blog:
    http://www.myvideosnapshots.com/wordpress-get-posts-with-custom-taxonomies-resolved.html
    This should give you a very very sweet and slick little loop pull posts by custom taxonomy.
    Use as many loops as you want.
    I also gave you some bonus code to prevent posts from duplicating.

Topic Closed

This topic has been closed to new replies.

About this Topic