0

Correct me if im wrong but is this right when searching for poet meta key a value in Wordpress ?

$args = array(
  'post_type' => 'clientorders',
  'meta_query' => array(
    array(
      'key' => 'installDDate',
      'value' => $date1,
      'compare' => '=',
    ),
  ),
);

1 Answer 1

1

Your syntax is correct, if the query isn't coming up with anything it'd be worth checking for typos. Is that double D in installDDate deliberate?

The reason it uses nested arrays is to allow for more than one meta key/value pair in the query, which can be combined with different relations. Each pair would have its own array at the innermost level.

1
  • Hi Chris - Yeah the installDDate is current and is within the post type clientorders. ive even tried `$date44 = '09-06-2024'; $args = array( 'post_type' => 'clientorders', 'meta_query' => array( array( 'key' => 'clientOrderDate', 'value' => $date44, 'compare' => '=', ), ), ); $results = get_posts($args); // Corrected constructor call if ($results->have_posts()) { echo "<p>Matching order date: $date44</p>"; // Display searched date echo "<ul>"; while ($results->have_posts()) { $results->the_post();'
    – Liam
    Commented Jun 10 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.