I can’t seem to get the relationship field working anymore – I just keep getting ‘No Matches Found’. If I had the search filter type it will indeed search & add the record that way, but it won’t show all the records on the left.
I’m not sure if it’s related, but I’m using custom post types. The particular one I’m working with at the moment consists of solely the title and ACF fields.
Hi @rywn
Thanks for the bug report, however I am a bit confused as to all the issues mentioned above.
Are you able to clearly list the steps to reproduce the issue?
Does the issue occur on newly created relationship fields?
I can reproduce it currently with all my relationship fields in the admin – I have a custom post type called ‘Team Members’ and I am trying to relationship them to a page. When I got to a page, there’s no Team Members listed over on the right side.
If I set up the relationship to allow for searching, I can find team members that way and add them.
This is one relationship that had existed previously, and when a new one is created either for these two post types, or with another custom post type and page, the same thing happens.
I can try to list exact steps and screenshots tomorrow if this is still confusing, but sadly my work computer is not accessible at the moment.
Hi @rywn
Thanks for the explanation, this is much clearer. However, you mentioned there are no members on the right hand side. Did you mean to say left?
The left side shows the available choices, and the right hand side shows the saved selection.
perhaps some screenshots would help.
Also, can you export the field group so I can review the field’s settings?
Sam here, ..exact setup, ..nothing showing n the left column (constant ‘loading’), ..search returns nothing.
Although I have a nested Relationship somewhere else on the same site calling a custom post type which works, ..but I tried switching the Post one to a CPT but it still did not work.
Surely! Yes, I meant left – sorry! That’s what happens when I answer right before bed.
And here’s the export code for both of the relationships shown above.
if( function_exists('register_field_group') ):
register_field_group(array (
'key' => 'group_53c93c1a57b90',
'title' => 'Bios Join',
'fields' => array (
array (
'key' => 'field_535ad94b471e0',
'label' => 'Bios',
'name' => 'bios',
'prefix' => '',
'type' => 'relationship',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'post_type' => array (
0 => 'team_bio',
),
'taxonomy' => '',
'filters' => array (
0 => 'search',
),
'elements' => '',
'max' => '',
'return_format' => 'object',
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'seamless',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
));
register_field_group(array (
'key' => 'group_53c982b23a920',
'title' => 'Page Blocks Join',
'fields' => array (
array (
'key' => 'field_53c982bbe7eab',
'label' => 'Page Blocks',
'name' => 'page_blocks',
'prefix' => '',
'type' => 'relationship',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'post_type' => array (
0 => 'pageblock',
),
'taxonomy' => '',
'filters' => array (
0 => 'search',
),
'elements' => '',
'max' => '',
'return_format' => 'object',
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'team_bio',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'seamless',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
));
endif;
I fixed mine by just deleting and remaking the field. Provided you use the exact same slug for the field you will not lose any data.
Hi @rywn
On the page load, an AJAX call will fire to load the choices on the left side. Can you view your console log and review the AJAX call.
What data is being sent? What data is being returned?
Hm, it looks like neither of the joins are sending along the post_type, which I imagine is probably part of the problem…
action:acf/fields/relationship/query
field_key:field_535ad94b471e0
nonce:9f1a98d75f
post_id:7332
max:
s:
post_type:
taxonomy:
action:acf/fields/relationship/query
field_key:field_53c982bbe7eab
nonce:9f1a98d75f
post_id:7332
max:
s:
post_type:
taxonomy:
And neither is getting any response back.
Hi @rywn
Can you elaborate more on the response. Does any JSON return, or simply a blank response?
I have a feeling that a PHP error is preventing the JSON from being returned. Can you enable debug mode, and review the JSON return data again?
http://www.advancedcustomfields.com/resources/how-to/debug/
Ahhah! When I turned on debug mode I got back an error in the AJAX for ACF regarding Relevanssi. Here’s the related errors (I believe I have them all, but reading xdebug in the response field is a pain).
Notice: Undefined index: post_type in /media/sf_web/wp0/wp-content/plugins/relevanssi/lib/search.php
Notice: Undefined index: s in /wp-content/plugins/relevanssi/lib/search.php
Notice: Undefined index: posts_per_page in /wp-content/plugins/relevanssi/lib/search.php
Notice: Undefined index: paged in /wp-content/plugins/relevanssi/lib/search.php
If I disable Relevanssi, the relationship fields are working as expected, but I rather need Relevanssi to uh, search through all these lovely custom fields I’m making, and it’s currently working just fine with both of them enabled with the last version of ACF. 🙁
Hi @rywn
Thanks for the update. Any chance you could contact the relevanssi devs to see if they have a solution?
I definitely can, but I’m not entirely sure what to contact them with in regards to what problem needs to be solved on their end. Are the fields something that don’t need to be defined and Relevanssi is simply not checking if they exist or not? Etc. 🙂
Hi @rywn
No worries. Just let them know of the thread here and that there is a conflict between relevanssi and ACF PRO on the relaitonship field which uses get_posts during an AJAX request.
Also let them know of the PHP errors you attached above as these point to code within the relevanssi plugin.
I’m not sure why the issue is occuring, but hopefully they can point us in the right direction
Cheers
E
Post started! Here’s the link – http://wordpress.org/support/topic/relevanssi-and-acf-pro-conflict?replies=0
From the devs over at Relevanssi:
For some reason, the query seems like a search so that Relevanssi catches it, and since it’s not a search, it’s missing critical parameters and Relevanssi is complaining.
Can you make that AJAX request look less like a search? Can you show me the code?
Hi @rywn
The code used to query posts can be found in the fields/relaitonship.php file starting on line 77.
If no search is entered, the $args['s']
will never be set, however $_POST[‘s’] is most likely always set. Perhaps relevansi is looking at the $_POST data instead of the $args?
Weirdly enough, one of the changes in the last (5.0.6, I just noticed there was a newer one) ACF patch seems to have fixed the problem.
Huzzah for accidental fixes? 😀
The topic ‘Relationship’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.