Home › Forums › ACF PRO › Archive.php with custom field filter (object post) › Reply To: Archive.php with custom field filter (object post)
Hi @bibi.lerici
The PHP error explains it quite well:
Warning: trim() expects parameter 1 to be string, array given in http://www.mydomain.com/wp-includes/meta.php on line 107
This is telling you that you can’t use an array as your meta compare:
$newstand_selettore_stand = explode(',', $_GET['newstand_selettore_stand']);
$meta_query[] = array(
'key' => 'newstand_selettore_stand',
'value' => $newstand_selettore_stand,
'compare' => 'LIKE',
);
Instead, loop through the array and add them like so:
<?php
$newstand_selettore_stand = explode(',', $_GET['newstand_selettore_stand']);
if( !empty($newstand_selettore_stand) ) {
foreach( $newstand_selettore_stand as $id ) {
$meta_query[] = array(
'key' => 'newstand_selettore_stand',
'value' => $id,
'compare' => 'LIKE',
);
}
}
?>
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.