Home Forums Front-end Issues Get Post/Pages based on ACF checkbox Reply To: Get Post/Pages based on ACF checkbox

  • Hi @elliot

    Thanks for responding.
    actually i code it before opening this support thread. my code is almost same as the above thread you linked but my problem is it’s not working with multiple values. means when the page / post contain multiple values ( actually it’s an array of values ) the relation code not working, and the above code is working only with two values but what if i have more than two values ?

    i have an ACF checkbox with many values ( like value1, value2, value3, … , value10 ). the above code may works fine for one or two value but how i should loop it to work with the array.

    also this is my code:

    	$checkbox_field = get_field( 'checkbox_field', $post->ID );
    	$checkbox_field_opts = implode( ", ", $checkbox_field);
    	$args = array(
    		'post_type'				=> 'page',
    		'post__not_in'			=> array( $post->ID ),
    		'posts_per_page'		=> $related_no,
    		'meta_query'			=> array(
    			'relation'		=> 'OR',
    				'key'		=> 'checkbox_field',
    				'value'		=>	$checkbox_field_opts,
    				'compare'	=>	'LIKE'

    i tried to implode it, but that’s not working too.