D
D
Dmitry2020-06-26 22:39:30
WordPress
Dmitry, 2020-06-26 22:39:30

How to pass a string from ACF to wp_query?

I have an ACF repeater where I created 2 lines (all posts have 2 lines or more):
1 line: [name | age | city ​​]
2nd line: [name | age | city ​​]

I want to pass the city field of 2 lines to wp_query. How can this be done?

My code is like this but it doesn't work :(

$rows = get_field('days_duration');
$first_row = $rows[0];
$cost_per_day = $first_row['cost_per_day' ]; // получаю в переменную ту самую строку и поле city.
$args = array(
        'post_type'		=> 'ration',
        'orderby'		=> 'meta_value_num',
  'order'			=> 'ASC',
  'meta_key'      => $rows, // передаю сам acf
  'meta_value'   	=> $cost_per_day, // передаю вот то самое поле
);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Olga, 2020-06-26
@Avilona

you need to use get_field instead of the_field
https://www.advancedcustomfields.com/resources/the...
https://www.advancedcustomfields.com/resources/get...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question