I created a Post Object field with “Filter by Post Type” set to “Page”. The site I am using this on has 233 published pages. When we attempt to use this Post Object field to select pages that we know exist and are published, they do not come up in the results.
For example, the site has 8 pages with the word “Alumni” in the title, but if I type in “alumni” only one of them comes back.
I’m guessing that this may have to do with the very large number of pages on the site. I’ve confirmed it is an issue on two sites using the same theme, both of which have a very large number of pages. But on another site that only has a few pages, also using the same theme, it is not a problem. Another distinction: on the two sites with many pages, nothing shows up in the dropdown until I’ve entered several letters, whereas on the site with few pages, as soon as I click on the field, without even typing anything, it initiates a search and lists several pages.
The problem is exactly what you suspect, the query to search the posts is timing out. ACF uses WP_Query() to search the posts. When searching WP_Query() does a “LIKE” search on the words entered on both the content and the title of the posts.
This can be exacerbated if you have any plugins installed or code that modify the searches in any way and can be even worse if this code is trying to also include custom fields in the search.
Thanks… my theme does make some modifications to search, specifically to add in custom fields since almost all page content is handled with ACF and not the post_content field. I’ll see if I can tweak these modifications not to run on AJAX calls.
Viewing 3 posts - 1 through 3 (of 3 total)
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