Skip to content
  • home
  • portfolio
  • web design journal
  • blog
    • adventure
    • san diego
    • projects
    • website design
Blog Quickbits WordPress Meta Query Mix Relation

WordPress Meta Query Mix Relation

By Forrest Smith - Drempd.com

Using a mix of 'And' and 'Or' operators in the meta_query portion of wordpress get posts query. Specifically with this one, I was looking for an event that had a tag specified by the $show variable, and where the date to see if it was current was either the start or end date of the event (the start date was the only required field in the admin side, so some events don't have end dates).

$args['meta_query'] = array(

  'relation' => 'AND',

   array(

      'key' => 'tags',

      'value' => '"'.$show.'"',

      'compare' => 'LIKE',

   ),

   array(

     'relation' => 'OR',

      array(

         'key' => 'event_date_end',

         'value' => date("Ymd000000"),

         'compare' => '>='

      ),

      array(

         'key' => 'event_date',

         'value' => date("Ymd000000"),

         'compare' => '>='

      )

   )

);

Posted on September 21, 2022December 13, 2022 in Quickbits
  • Adventure

    • adventure
    • gravelgrinding
    • hiking
    • running
  • The Built Environment

    • architecture
    • urbanity
  • Locations

    • san diego
    • portland
  • Freelance Life

    • freelancing
    • productivity
  • Web Dev

    • css
    • entrepreneurship
    • git
    • handlebars
    • html
    • inkscape
    • photoshop
    • php
    • sass
    • web design
    • web development
    • saphire

drempd | san diego, ca


home contact

adventures san diego urbanity and architecture projects stream website design

portfolio resume san diego web design freelance web designer

custom web design responsive web design website maintenance