Can't make the sorting by meta field in an array inside a ACF select field with multiple choice?

Hello. Generally such a thing make the filter by custom field ACF select multiple choice and once tried to implement it nothing is impossible, it turns out not even to just bring the post with the values of the meta fields which I need
$args = array(
'post_type' => 'courses',
'showposts'=> 100 ,
'meta_query' => array(
array(
 'key' => 'Vyborov',
 'value' => get_post_meta(8741 , 'Vyborov', true),
),
),
);

$query = new WP_Query( $args );

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


this code would seem should get the page with id 8741 but no, he does not show nothing please help
March 19th 20 at 09:06
1 answer
March 19th 20 at 09:08
1st look here

2nd - try to get rid of the Russian characters in the names of meta fields
'key' => 'Vyborov',


3E - a to test use the real values
'value' => 12 or 'value'=> array('12','13')


Here's the working piece of code + validation attributes
$args = array(
 'post_type' => 'product',
 'post_status' => 'publish',
 'ignore_sticky_posts' => 1,
 'posts_per_page' => - 1,
 'meta_query' => array(
array(
 'key' => '_visibility',
 'value' => array( 'catalog', 'visible' ),
 'compare' => 'IN'
)
),
 'tax_query' => array(
array(
 'taxonomy' => 'product_cat',
 'field' => 'term_id', //This is optional, as it defaults to 'term_id'
 'terms' => array( 673, 578, 338 ),
 'operator' => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
)
)
 );
The fact that I'm finishing it for the man, and there's all the meta fields in Russian. In this meta box is an array of Russian Words. And the link I've already read it 10 times and nothing happens. And I have tried as you have in the example but it works if the field does not contain an array, and I have each field contains an array

array(
 'key' => 'Vyborov',
 'value' => array( 'Python', 'supervised Learning' ),
 'compare' => 'IN'
 ),


that's not working.
Here's how :
array(
 'key' => 'Vyborov',
 ),

displays all articles with the meta field
so as you say will not work because the meta field is not a string and not a number but an array - max commented on March 19th 20 at 09:11
so as you say will not work because the meta field is not a string and not a number but an array

It will, if the request to consider a not an array, but a string.

Let me explain. If metapola the array, but not necessarily in its serialized form, and it is nothing more than a string representation of this array.

It turns out that You need to "value=" insert only it's string representation.
And if you carefully read the description get_post_meta , it is possible to obtain
'value'=>get_post_meta(8741 , 'Vyborov', false)[0]


Although the rake face. - rodolfo33 commented on March 19th 20 at 09:14

Find more questions by tags WordPress