Forums › Forums › Search & Filter Pro › ACF Values Not Being Picked Up
Tagged: acf, advanced custom fields, labels, menus, select
- This topic has 4 replies, 2 voices, and was last updated 8 years, 11 months ago by
Ross.
-
Anonymous(Private) February 3, 2016 at 8:34 pm #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(Private) February 3, 2016 at 8:46 pm #36176Hey 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.
Ross Moderator(Private) September 22, 2016 at 5:08 pm #59608Hey 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
-
AuthorPosts