Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

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

Viewing 5 posts - 1 through 5 (of 5 total)
  • Daniel Taylor
    #36144

    Hello,

    I have the latest version of ACF and also Search and Filter Pro installed on my test site located here: http://lcbp.org/bibliodev/media-center/publications-library/publications-database/

    I have two fields on there that are ACF fields at the moment. I’m using the Post Meta field within Search and Filter Pro and check marked the “is ACF Field?” on both. The first one is called Publication Author and is using the Post Object ACF Field. It populates a custom post type I created called Scientists into it and returns the post object. The Search and Filter Pro only seems to display the ID of the scientist in the dropdown and not the title of the scientist post type.

    The second field is Publication Type. This is also an ACF field. It uses the taxonomy field and loads in the Publication Type taxonomies. It also appears to be displaying an ID and not the title.

    Is there any way I can get the Search and Filter pro to display the proper names of the ACF field selections? Thanks.

    Daniel Taylor
    #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.

    Daniel Taylor
    #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 5 posts - 1 through 5 (of 5 total)

The topic ‘ACF Values Not Being Picked Up’ is closed to new replies.