Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › ACF – Relationship Field
This topic contains 7 replies, has 2 voices, and was last updated by gteigland 6 years, 1 month ago.
- AuthorPosts
- March 9, 2018 at 4:01 pm #17065
Please see password to view url. Click on menu links above such as – About Us to see the search function
The issue I’m having is with the Custom fields I added using ACF. All of them work fine for dropdown multiselect – {get_values}
https://www.awesomescreenshot.com/image/3224446/6d1d0a4bc30d388ca7e5e2eda6e8be72EXCEPT my relationship fields.
For example:
1. Under “By Name” in frontend you will see the one post i added “Adox 300”. So for By Name and By Image Size it’s all good.
2. However under By Manufacturer & By Lens / Accessories you will see that it’s a coded mess under my dropdown options. Those 2 fields are “Relationship fields in ACF in “Cameras”
https://www.awesomescreenshot.com/image/3224456/800ca50a459629000a2a326aa8059bba3. I am able to add that custom field so the “results” are working but obviously not showing the proper text.
Before purchasing I was told that all ACF fields work with this plugin.
Thanks!
March 9, 2018 at 4:07 pm #17066Hi!
The issue is that Relationship fields are not text based fields – they does not store the actual information, they store serialized information as a reference to some other field/object, not the actual value. Because of that, it is not possible to use them in a filter – as the values are only referenced, not stored in the field itself.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 9, 2018 at 4:35 pm #17070Ok so this is a HUGE Necessity for me. Can I hire you guys to fix this? Otherwise my searches are pointless. I need to be able to search within these fields.
Think of it this way. If you are searching for a product and need to search by manufacturer. Very common thing. I’m open to suggestions if there is another way to do this. is there way a translate them like ACF does. Because they obviously translate them.
Also im sure there are many others that need this function.
Gene
March 9, 2018 at 4:36 pm #17071As you state:
“they store serialized information as a reference to some other field/object”
is there a way to add that code into your plugin so it knows how to translate them?
This is the code i use to have them show up as text within my template file: (twig)
{% for item in post.get_field(‘manufacturer’) %}Here’s the full php call:
<?php $manufacturer = get_field( ‘manufacturer’ ); ?>
<?php if ( $manufacturer ): ?>
<?php foreach ( $manufacturer as $post ): ?>
<?php setup_postdata ($post); ?>
“><?php the_title(); ?>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?Heres a link to their documentation if that helps:
https://www.advancedcustomfields.com/resources/relationship/
https://www.advancedcustomfields.com/resources/acf-fields-relationship-result/March 9, 2018 at 5:27 pm #17075Hi!
I took a closer look at those fields, I may have found a possible solution. Please note that this may not work correctly in all cases.
So the problem with repeaters is, that they don’t have a unified structure, so I can’t add a global solution to the plugin to deal with them. For each type there must be a custom code made. Lukcily in your case, the repeater contains post type objects for both the lenses and the manufacturers.
What I did was, I made a custom function into the functions.php file in your child theme directory via FTP. This function will unserialize this ACF object, then gets the corresponding custom post title and the ID, and then replaces the old “jibberis” values in the field with these new, readable ones.
Once again, this may not be the perfect solution, but it should do the trick.
This is the function I added there, I will keep it in this thread for archivation purposes:
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 9, 2018 at 8:52 pm #17076wow that is genius! thanks so much. If you ever had this function into your pro plugin you will make a lot of people happy. Thanks again for your GREAT support!!!
March 9, 2018 at 8:53 pm #17077You are very welcome, thank you for you kind words!
If you don’t mind, in a few hours I will close this topic and mark it as resolved, feel free to open another one if you have other questions or issues.
If you like the plugin, feel free to rate it on your codecanyon downloads page, it’s greatly appreciated.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 9, 2018 at 8:56 pm #17078I went ahead and put in my rating. Sound good. Thanks again and have a great weekend!
- AuthorPosts
The topic ‘ACF – Relationship Field’ is closed to new replies.