Home › Forums › General Issues › Meta query for post object? › Reply To: Meta query for post object?
I have now read section 4 of that article, but I don’t really understand it because I’m not too hot on mySQL. But either way, I’ve added the following to my functions file :
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 I’m trying to query like this …
$images_query = new WP_Query([
'posts_per_page' => -1,
'post_type' => 'images',
'meta_query' => [
[
'key' => 'authors_%_people',
'compare' => '='
'value' => ['85'],
],
],
]);
Any ideas why this wouldn’t be working? Could it be because I allow multiple values in the people post_object field?
What do you mean by “create a custom field for this query”?
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.