Support

Account

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',
    
            );
    		
    	}
    	
    }
    
     ?>