• Resolved floridahikes

    (@floridahikes)


    Hi, Bill. I’ve dug through your website and this forum, but I’m still beyond puzzled why the query structure I’m trying to do won’t work.

    I want to display posts that are within the categories of florida-trail and northwest-florida (the posts must be tagged with both categories) and only show the posts from that list that have a tag of favorites.

    I’ve tried this:
    [display-posts category=”northwest-florida,florida-trail” tag=”favorites” posts_per_page=”-1″ order=”ASC” orderby=”title” image_size=”featured-page” include_excerpt=”true”]

    Which brings up all posts in the category of northwest-florida with a tag of favorites, but does not restrict the posts only to those in both the florida-trail category AND the northwest-florida category

    And this:
    [display-posts post_type=”post” taxonomy=”category” tax_term=”florida-trail,northwest-florida” taxonomy_2=”tag” tax_2_term=”favorites”]

    Which shows no posts at all

    There must be a simple solution but I’ve been going crazy digging around your documentation trying to figure it out, and no luck.

    Many thanks.

Viewing 1 replies (of 1 total)
  • Plugin Author Bill Erickson

    (@billerickson)

    Thanks for the message, and I apologize for how difficult the taxonomy query can be. You’re really close!

    The Tag taxonomy actually has a slug of “post_tag”, which is why you’re getting no results.

    Also, the default operator for taxonomy queries is IN, so it’s finding posts in either of those categories. You need to change that to an AND operator (only posts in both categories).

    You don’t need the post_type=”post” parameter since that’s the default post type queried.

    This should hopefully work for you:

    [display-posts taxonomy=”category” tax_term=”florida-trail,northwest-florida” tax_operator=”AND” taxonomy_2=”post_tag” tax_2_term=”favorites”]

Viewing 1 replies (of 1 total)
  • The topic ‘How to craft a query properly to only show posts with an AND relationship’ is closed to new replies.