Forums Forums Search & Filter Pro ACF Values Not Being Picked Up

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #36174

    For anyone with a similar issue, I created a work-around for this. I created a blank, normal drop down menu with ACF and dynamically loaded the values into the dropdown using a function within functions.php. You can see an example of this on this page: http://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/. I then substituted their example with a normal loop to load in my scientists into the $field[‘choices’] array.

    Search & Filter Pro picks up plain drop down menus just fine, so this worked well for me.

    Here is the code I put in my functions.php in case it helps anyone:

    function my_acf_load_field( $field ) {
    	$field['choices'] = array();
    	$sciArgs = array(
    		'post_type' => 'scientists'
    	);
    	$sciQuery = new WP_Query($sciArgs);
    	if ($sciQuery->have_posts()) : while ($sciQuery->have_posts()) : $sciQuery->the_post();
    		global $post;
    		$field['choices'][$post->post_name] = get_the_title();
    	endwhile; endif;
    
    	return $field;
    	wp_reset_postdata();
    }
    add_filter('acf/load_field/name=publication_person','my_acf_load_field');
    Ross Moderator
    #36176

    Hey Daniel

    I was just about to link this ticket:

    https://support.searchandfilter.com/forums/topic/filter-dropdown-options/#post-34366

    We don’t officially support all the different field types just yet (and they seem to be growing everyday) – but little work around like this are always available.

    I will be adding better, integrated support over time 🙂

    Thanks for updating with your example.

    Anonymous
    #36246

    Thanks for the reply as well. Looking forward to the improvements.

    Ross Moderator
    #59608

    Hey Daniel

    Just to let you know we’ve included support for all the relationship fields, let me know if you want to test before we release 🙂

    Best

Viewing 4 posts - 1 through 4 (of 4 total)