• Resolved AngelEyes

    (@clustervision)


    I have a meta key called Affiliate and a value that is the same over several posts. I can’t get the query to return anything as expected. the loop needs to be dynamic for each page so I’m getting the value of that meta key (custom field) and saving it as $affiliate. I’m then plugging it into my query but i can’t get it to work. Does this still work? What am i doing wrong? many thanks

    http://pastebin.com/LKEihjgP

    It should be noted that i’m successfully getting my affiliate value and echoing it out on the page. it is the query that isn’t working.

Viewing 1 replies (of 1 total)
  • Thread Starter AngelEyes

    (@clustervision)

    well… i seem to have had some luck with this format-

    $args = array(
    'post_type' => 'any',
    'meta_query' => array(
    array(
    'key' => 'Affiliate',
    'value' => $affiliate,
    )
    )
    );

    it seems like wordpress wanted the query nested inside ‘meta_query’ even though it wasn’t multiple meta values. I think this contradicts what is inside the codex. Anyways this works!

Viewing 1 replies (of 1 total)

The topic ‘WP_Query by Meta Key & Value’ is closed to new replies.