[resolved] Query_posts using multiple custom values (meta_value) (3 posts)

  1. elandgren
    Posted 7 years ago #


    I've been trying to generate a query_post call to get a list of posts that have 2 or more meta_values, but it's been impossible.

    Basically, let's say that all posts have a custom field called "age".. and I want to get (using query_posts function) all posts which have age=22 and age=25.

    I've tried:

    but, obviously, I've got no success... Anyone knows how to solve this?

  2. MichaelH
    Posted 7 years ago #

    Can't do that with the template tag, query_posts(), custom field paramters.

    You'd have to get all posts with a meta_key=age then filter (if test) in your Loop.

    Our build a custom query that did that but that's more complicated. Ref: Displaying_Posts_Using_a_Custom_Select_Query

  3. elandgren
    Posted 7 years ago #

    Gracias! It's easier, faster and simplier to adjust my blog to query_post() schema instead of diving into mySQL.

Topic Closed

This topic has been closed to new replies.

About this Topic