This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

ACF – Relationship Field

ACF – Relationship Field

Home Forums Product Support Forums Ajax Search Pro for WordPress Support ACF – Relationship Field

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #17065
    gteiglandgteigland
    Participant

    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/6d1d0a4bc30d388ca7e5e2eda6e8be72

    EXCEPT 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/800ca50a459629000a2a326aa8059bba

    3. 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!

    #17066
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    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.

    #17070
    gteiglandgteigland
    Participant

    Ok 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

    #17071
    gteiglandgteigland
    Participant

    As 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/

    • This reply was modified 8 years, 3 months ago by gteiglandgteigland.
    • This reply was modified 8 years, 3 months ago by gteiglandgteigland.
    • This reply was modified 8 years, 3 months ago by gteiglandgteigland.
    #17075
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    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:

    #17076
    gteiglandgteigland
    Participant

    wow 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!!!

    #17077
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You 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.

    #17078
    gteiglandgteigland
    Participant

    I went ahead and put in my rating. Sound good. Thanks again and have a great weekend!

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘ACF – Relationship Field’ is closed to new replies.