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.
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.
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;
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.
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?
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. 🙁
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
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?
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?
You must be logged in to reply to this topic.
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!
2022 was a big year for Advanced Custom Fields, with more capabilities, a new generation of ACF Blocks, a refreshed UI, and a new home. Our year in review post looks at advancements we’ve made and offers a glimpse of the future.— Advanced Custom Fields (@wp_acf) January 6, 2023
© 2023 Advanced Custom Fields.