Home Forums Bug Reports Search not working on Relationship Field in WordPress 4.0


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.

Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘Search not working on Relationship Field in WordPress 4.0’ is closed to new replies.