A
A
Alexey Vesnin2018-07-26 09:55:17
WordPress
Alexey Vesnin, 2018-07-26 09:55:17

Why doesn't meta_query work with ACF fields?

Hello. The selection of posts by ACF fields does not work, I can not understand what the problem is. Posts like tours have custom ACF fields,
I want to get posts by custom field price (ACF)

$args7 = array(
    'post_type' => 'tours', 
    'meta_query' => array(
     array(
      'key' => 'tour_price',
      'value' => array( 1000, 7000 ),
      'compare' => 'BETWEEN' 
     ) 
    ) 
); 


$query = new WP_Query($arg7); 

if ($query->have_posts()): while ($query->have_posts()): $query->the_post(); ?>

But nothing works, if I work with taxonomy terms, then everything works, but meta_query does not want to work in any form, although examples are described in the ACF documentation, what's wrong ???? https://www.advancedcustomfields.com/resources/que...

Answer the question

In order to leave comments, you need to log in

5 answer(s)
C
campusboy, 2018-07-26
@alexvdv

Hello. You store the query parameters in the $args7 variable, and pass another (unknown, empty) $arg7 variable to the WP_Query() class. Therefore, it doesn't work.

V
Vladimir Kulikov, 2021-06-08
@it_proger29

$wp_query = array(
    'post_type' => 'page',
    'posts_per_page' => 4,
    'meta_query' => [
        'relation' => 'AND',
    ]
  );

  if(isset($_GET["priceMin"]) or isset($_GET["priceMax"])){
    $priceMin = $_GET["priceMin"];
    $priceMax = $_GET["priceMax"];
    if($priceMin or $priceMax){
      $wp_query['meta_query'][] = array(
        'priceMinMax_query' => array(
          'key' => 'price',
          'value' => array($_GET["priceMin"], $_GET["priceMax"]), // значение в промежутке от-до
          'compare' => 'BETWEEN',
          'type' => 'NUMERIC',
        ),
      );
    }
  }

V
Vadim Bogomazov, 2014-12-17
@bogomazov_vadim

As far as I understand, you need to read this and this

P
Pavel Radkov, 2014-12-17
@paulradzkov

Almost perfect solution: cssdeck.com/labs/8qsqyyqr
And "almost" because when the menu wraps over two or more lines, the last item of the penultimate line is indented from the right edge.

S
Sergey, 2014-12-17
@SKolt

So undo this very last indent, there are special pseudo-classes:

selector:first-child{стили} /*Первый элемент родителся*/
selector:last-child{стили} /*Первый элемент родителся*/

And there is also nth-child - in general, you can put your own style on each element. But this is if you use the plate, as you yourself suggested.
If you use CSS3 FlexBox, this task is solved elementarily. Just add the following code to the block that contains the menu items.
A simple example: codepen.io/anon/pen/emzJja
PS: well, don't forget about prefixes. Flex is new, some browsers don't understand it ;-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question