Home › Forums › ACF PRO › Post Object modify filter › Reply To: Post Object modify filter
Update
I managed to make it filter based on 2 custom fields, but it is not searching by title now
function filter_products_by_sku( $args, $field, $post_id ) {
$the_search = $args['s'];
unset($args['s']);
$args['meta_query'] = array(
'relation' => 'OR',
array(
'key' => 'sku_number',
'value' => $the_search,
'compare' => 'LIKE',
),
array(
'key' => 'old_id',
'value' => $the_search,
'compare' => 'LIKE',
)
);
return $args;
}
add_filter('acf/fields/post_object/query/key=field_5f58a23b95d62', 'filter_products_by_sku', 10, 3);
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.