I have the problem not to get the meta_query working.
Category 5 are ContactPersons with an ACF 'bereich' for a category.
This is the code:
$cat=wp_get_post_categories( get_the_ID(), array( 'fields' => 'ids' ) );
array_pop($cat);
$c = get_posts(array(
'numberposts' => -1,
'post_type' => 'post',
'category' => 5,
'meta_query' => array(
array(
'key' => 'bereich',
'value' => $cat,
'compare' => '='
)
)
));
}
field 'bereich' is an array of taxonomy category and same looking the $cat. The array_pop … I know the system 2 elements, just need one than its the same as 'bereich'. LIKE brings me all of the parent. IN also doesn't work.
I also tried this:
$c = get_posts(array(
'numberposts' => -1,
'post_type' => 'post',
'category' => 5,
'tax_query' => array(array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $cat)),));
}
It does not work!
Please help,
Tom