Skip to main content
Tweeted twitter.com/#!/StackWordPress/status/454235395019268096

I've been stuck on a problem for a while now and i cantI can't seem to figure it out.

I want to query posts and only display them if theytheir 2 meta values checked contain the ones iI have queried.

For example: If

If a post had 123 and 321 then iI want them to be displayed. But if it had 123 and 123 then it shouldntshouldn't be displayed and vice versa.

I have been looking at this code and iI cant figure it out:

array( 'key' => 'featured', 'value' => 'yes', 'compare' => 'NOT NULL', ), array( 'key' => 'type', 'value' => 'event', 'compare' => 'NOT NULL', )

array(
       'key' => 'featured',
       'value' => 'yes',
       'compare' => 'NOT NULL',
    ),
 array(
       'key' => 'type',
       'value' => 'event',
       'compare' => 'NOT NULL',
    )

So just to clarify; if feauted is yes AND type if event it should be displayed,clarify:

  • if featured value is "yes" AND type value is "event" => it should be displayed

but if it was featured is yes AND type is party then it shouldnt be displayed.

  • if featured value is "yes" AND type value is "party" => it shouldn't be displayed.

Sorry if this doesnt make sense.

Thanks, Dazeh.

I've been stuck on a problem for a while now and i cant seem to figure it out.

I want to query posts and only display them if they 2 meta values checked contain the ones i have queried.

For example: If a post had 123 and 321 then i want them to be displayed. But if it had 123 and 123 then it shouldnt be displayed and vice versa.

I have been looking at this code and i cant figure it out:

array( 'key' => 'featured', 'value' => 'yes', 'compare' => 'NOT NULL', ), array( 'key' => 'type', 'value' => 'event', 'compare' => 'NOT NULL', )

So just to clarify; if feauted is yes AND type if event it should be displayed, but if it was featured is yes AND type is party then it shouldnt be displayed.

Sorry if this doesnt make sense.

Thanks, Dazeh.

I've been stuck on a problem for a while now and I can't seem to figure it out.

I want to query posts and only display them if their 2 meta values checked contain the ones I have queried.

For example:

If a post had 123 and 321 then I want them to be displayed. But if it had 123 and 123 then it shouldn't be displayed and vice versa.

I have been looking at this code and I cant figure it out:

array(
       'key' => 'featured',
       'value' => 'yes',
       'compare' => 'NOT NULL',
    ),
 array(
       'key' => 'type',
       'value' => 'event',
       'compare' => 'NOT NULL',
    )

So just to clarify:

  • if featured value is "yes" AND type value is "event" => it should be displayed

but

  • if featured value is "yes" AND type value is "party" => it shouldn't be displayed.

Sorry if this doesnt make sense.

Thanks, Dazeh.

Source Link
Daz
  • 138
  • 7

Query Multiple Meta Values and display only when it has both meta values

I've been stuck on a problem for a while now and i cant seem to figure it out.

I want to query posts and only display them if they 2 meta values checked contain the ones i have queried.

For example: If a post had 123 and 321 then i want them to be displayed. But if it had 123 and 123 then it shouldnt be displayed and vice versa.

I have been looking at this code and i cant figure it out:

array( 'key' => 'featured', 'value' => 'yes', 'compare' => 'NOT NULL', ), array( 'key' => 'type', 'value' => 'event', 'compare' => 'NOT NULL', )

So just to clarify; if feauted is yes AND type if event it should be displayed, but if it was featured is yes AND type is party then it shouldnt be displayed.

Sorry if this doesnt make sense.

Thanks, Dazeh.