title: Getting posts IDs that match a specific meta_key value in WordPress
body: <p>I am working on my first Wordpress child theme, for an existing theme.</p>
  
  <p>The wp_postmeta table has the following columns:</p>
  
  <pre><code>meta_id
  post_id
  meta_key
  meta_value
  </code></pre>
  
  <p>A few meta keys of interest to me:</p>
  
  <pre><code>book_title
  exhibition_name
  </code></pre>
  
  <p>I would like to get all the book titles, and their corresponding post IDs, that match a specific exhibition name.</p>
  
  <p>If I use the get_post_meta call, the parameter $post_id is required, so it's a dead end (as far as I know).</p>
  
  <p>Any idea how I can accomplish what I would like, using the WordPress API?</p>
  
  <h1>Solution</h1>
  
  <p>The answer was provided by @Junaid but the syntax had a minor error in it:</p>
  
  <pre><code>$args = array(
      'post_type' =&gt; 'post',
      'meta_query' =&gt; array(
          array(
              'key' =&gt; 'exhibition_name',
              'value' =&gt; 'Science Exhibition'
          )
      )
  );
  
  $query = new WP_Query($args);
  
  if ($query-&gt;have_posts()) {
      while ($query-&gt;have_posts()) {
          $query-&gt;the_post();
          $post_id = get_the_ID();
          $title = get_post_meta($post_id, 'book_title');
      }
  }
  </code></pre>