R
R
rkfddf2020-06-17 16:33:38
WordPress
rkfddf, 2020-06-17 16:33:38

Why is wordpress filter not working with wp_query()?

I was killed about the question of the filter in wordpress through wp_query ().

<?php 
    $args = array(
    'post_type' => 'sale',
          'key' => 'price',
          'value' => '200',
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
  while ( $query->have_posts() ) {
    $query->the_post();
    echo '<li>' . get_the_title() . '</li>';
  }
} else {	// Постов не найдено }
wp_reset_postdata();
    ?>

This code outputs all records from an arbitrary "sale" type, but does not want to filter by key and value in any way. I tried other types and fields and values, the result is the same. What is the reason?
5eea1ce3ac974222793896.png5eea1cec85f99509662890.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
its2easyy, 2020-06-17
@rkfddf

There are two formats for postmeta, you need to use one of them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question