Home › Forums › General Issues › Meta query for post object? › Reply To: Meta query for post object?
I cannot see where I’m going wrong.. Perhaps it’s relation in the meta_query ? Here is what I have now.
In my function.php
function my_posts_where( $where ) {
global $wpdb;
$where = str_replace(
"meta_key = 'authors_",
"meta_key LIKE 'authors_",
$wpdb->remove_placeholder_escape( $where )
);
return $where;
}
add_filter( 'posts_where', 'my_posts_where' );
And on my archive-images.php ….
$author = 85; // This will eventuall be pulled from get_query_var('author')
$images_query = new WP_Query([
'suppress_filters' => FALSE,
'posts_per_page' => -1,
'post_type' => 'images',
'meta_query' => [
//'relation' => 'OR',
//'relation' => 'AND',
[
'key' => 'authors_%_people',
'compare' => 'LIKE',
'value' => '"'.$author.'"',
],
],
]);
What am I doing wrong?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.