Support

Account

Home Forums Backend Issues (wp-admin) Relationship Field Search Won't Work for Custom Post Type

Solving

Relationship Field Search Won't Work for Custom Post Type

  • Hey guys!

    The search is not working with custom post types on a relationship field. I debugged it quite extensively using the acf/fields/relationship/query filter as well without any luck.

    It seems that the search doesn’t work only for the custom post types. When I programmatically change the post type to ‘post’, search starts working.

    The ‘s’ query parameter doesn’t work.

    Any help here would be highly appreciated as we are struggling with issue for a long time now and we have over 600 trips which we have to scroll and choose at the moment manually.

    Thank you

  • UPDATE

    Fixed myself. The problem was caused by the modification of the search using in admin using pre_get_posts. I would consider this a bug with ACF because if you modify pre_get_posts, ACF should still work.

    Anyway, I struggled with this issue for hours. Leaving this comment here for someone else who’s facing similar issues.

    Feel free to reply here if you get stuck; hopefully, I’ll respond soon.

  • a pre_get_posts filter will effect all queries unless conditions are added for excluding queries based on something in the query. Or in this case you could exclude queries run during AJAX requests. ACF uses a standard WP_Query to get the posts/search results so it will be affected by any pre_get_posts filters active on the site.

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

You must be logged in to reply to this topic.