I have a custom pre_get_post() hook that adds meta fields to be searched for the search. This seems to interfere with how ACF does it db search.
On my search.php page – i have get_field(‘gallery’) in the loop.
It returns the total number of images in the gallery field type, not the array of arrays that is returned on every other normal page / post.
var_dump( get_field(‘gallery’) ) gives me total number of arrays in the gallery field on search.php.
var_dump( get_field(‘gallery’) ) on page/post give me array( array( ‘stuff’), array(‘sutff’) )
Here is the debug log output.
[01-Apr-2015 19:12:13 UTC] WordPress database error Unknown column ‘wp_postmeta.meta_key’ in ‘where clause’ for query SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = ‘acf-field’ AND ((wp_posts.post_status = ‘publish’)) AND wp_posts.post_name = ‘field_54fb32cdfe852’ OR (( wp_postmeta.meta_key = ‘basic_info_long_description_in_english’ AND ( UPPER ( wp_postmeta.meta_value ) LIKE ‘%goal%’ ) )) ORDER BY wp_posts.menu_order ASC, wp_posts.post_title ASC LIMIT 0, 1 made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/hipgive/search.php’), genesis, do_action(‘genesis_loop’), call_user_func_array, HIPGive_search_page_loop, include(‘/themes/hipgive/partials/project/project-summary-display-loop.php’), include(‘/themes/hipgive/partials/project/project-display-summary.php’), get_field, get_field_object, acf_get_field, _acf_get_field_by_key, get_posts, WP_Query->query, WP_Query->get_posts, QM_DB->query
So, is there a way to tell my custom pre_get_post() hook to not interfere with ACF when it is doing it’s search?
@hyperarts, just trying to clean up some older topics :), I had a feeling that you’d either figured it out or moved on by now. I have seen some problems in the past with things interfering with ACF. Just wanted people to know that if they have similar problems that if they include code then it’ll be more likely to be looked at, as well as the fact that the forums here are getting more attention now so hopefully a question won’t go more than a year without a reply in the future.
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!
Sorry for the issues with ACF's API SSL certificate this morning. We've resolved it and your activations and downloads should be back to normal again. Thanks! ^LG— Advanced Custom Fields (@wp_acf) November 2, 2022
© 2022 Advanced Custom Fields.