Home › Forums › Bug Reports › Search not working on Relationship Field in WordPress 4.0
I noticed that the search system inside the Relationship Fields is not working for WP 4.0.
Both ACF versions 4.3.8 and 4.3.9 are working fine with WP 3.9.1, but none of them work with WP 4.0.
Basically you type something in the search bar and nothing happens…
I am facing similar issue. Search in relationships is not working after I upgraded to WP 4.
Problematic for me too.
It only fails when WP_DEBUG is True. “Notice: like_escape is deprecated.” So it seems like somewhere in ajax handler there is like_escape call that is deprecated in WP 4.0.
This boils down to line 116 in advanced-custom-fields/core/fields/relationship.php:
$where .= " AND " . $wpdb->posts . ".post_title LIKE '%" . esc_sql( like_escape( $title ) ) . "%'";
Using WordPress 4.0 syntax, this is now:
$where .= " AND " . $wpdb->posts . ".post_title LIKE '%" . esc_sql( $wpdb->esc_like( $title ) ) . "%'";
(this works even when WP_DEBUG is true)
Search also does not work in relationship fields in Advanced Custom Fields Pro when searching on a custom post type. Regardless of what I enter in the search field, I get “no matches found.”
Search works fine for normal WP posts.
The code modification suggested above by bivald does not apply to ACF 5.0 since the file structure is completely different.
I am running ACF 5.0 and WordPress 4.1.
Having the same issue here as well. Doesn’t work for Page Link fields either. Always returns “No matches found”. Doesn’t appear to be any plugin conflicts either. I know this thread is a little old. Any luck anyone? Thanks in advance!
Did you try the WP_DEBUG? Because to me there was a some other plugin throwing Notice/Warning in the AJAX call and thus the JSON response which shows the results was corrupted.
You can put WP_DEBUG true, and check from Chrome developer tool’s network tab the ajax calls, and see if their results look normal or not.
Thank you Jari! Like a dolt I should have done the disable all plugins and then reenable until there may be a conflict. Oddly it appears to be Relevanssi Premium that’s causing the conflict. Have yet to test it but I think the non-premium version is fine. The network tab just seemed to have admin-ajax.php timing out when the calls were being made. When it comes to AJAX though (let alone what’s under the hood in WP admin) I’m over my head.
Sorry for the double post but just confirmed that Relevanssi (non-premium) version also causes the issue. No idea how to troubleshoot from here.
This is an issue with the Post Object as well. I was able to overcome it by adding all taxonomies to the taxonomies field vs leaving that field blank to “all taxonomies” – also had Relevanssi enabled.
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!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.