Finds nothing from Custom Fields
-
I can’t seem to find any custom fields with this. If you search for “absolut” it does find page https://www.miksologia.fi/alkoholit/ where absolut is mentioned but it does not find pages https://www.miksologia.fi/alkoholi/absolut-vodka/ or https://www.miksologia.fi for example. Lite mode does not help.
The page I need help with: [log in to see the link]
-
Hi @jarkko71k,
Thank you for your message.
Could you please send me a screenshot of the post settings page where you have the ACF field with the search value?
Best,
MateuszNot totally sure if I understand what you mean but here’s a try: https://paste.pics/4c8ae498017646af47c99bb3aaea8640
Quoting Lionel Richie: “Hello?”
@jarkko71k Can I ask you to run a little test? Download and install this plugin version. Then do some test searches. An acf-better-search.log file should be created in the root directory of your WordPress. Please send me its contents, it will allow me to try to understand the problem.
Do you have access to phpMyAdmin to be able to do an additional test in the form of an SQL query?
Here’s the log content of some searches:
2023-09-05 13:48:47 : SELECT DISTINCT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta AS a ON ( a.post_id = wp_posts.ID ) LEFT JOIN wp_postmeta AS b ON ( (( b.post_id = a.post_id )) AND (( b.meta_key LIKE CONCAT( ‘_’, a.meta_key ) )) ) LEFT JOIN wp_posts AS c ON ( ( c.post_name = b.meta_value ) AND ( c.post_type = ‘acf-field’ ) AND (( c.post_content LIKE ‘%:”text”%’ ) OR ( c.post_content LIKE ‘%:”textarea”%’ ) OR ( c.post_content LIKE ‘%:”wysiwyg”%’ ) OR ( c.post_content LIKE ‘%:”select”%’ ) OR ( c.post_content LIKE ‘%:”checkbox”%’ ) OR ( c.post_content LIKE ‘%:”radio”%’ )) ) WHERE 1=1 AND wp_posts.ID NOT IN (1464) AND ( wp_term_relationships.term_taxonomy_id IN (67) ) AND ( ( ( b.meta_id IS NOT NULL ) AND ( c.ID IS NOT NULL ) AND ( a.meta_value LIKE ‘%jamaica%’ ) ) OR ( ( wp_posts.post_title LIKE ‘%jamaica%’ ) OR ( wp_posts.post_content LIKE ‘%jamaica%’ ) OR ( wp_posts.post_excerpt LIKE ‘%jamaica%’ ) ) ) AND ((wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘page’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘attachment’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘alkoholi’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘drinkki’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘valineet’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’))) GROUP BY wp_posts.ID ORDER BY wp_posts.post_title LIKE ‘{332308f4c0dbaed97fd267487e343edd859a2380bfd95baacf7ad67d9da0f29a}jamaica{332308f4c0dbaed97fd267487e343edd859a2380bfd95baacf7ad67d9da0f29a}’ DESC, wp_posts.post_date DESC LIMIT 0, 50
2023-09-05 13:48:59 : SELECT DISTINCT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta AS a ON ( a.post_id = wp_posts.ID ) LEFT JOIN wp_postmeta AS b ON ( (( b.post_id = a.post_id )) AND (( b.meta_key LIKE CONCAT( ‘_’, a.meta_key ) )) ) LEFT JOIN wp_posts AS c ON ( ( c.post_name = b.meta_value ) AND ( c.post_type = ‘acf-field’ ) AND (( c.post_content LIKE ‘%:”text”%’ ) OR ( c.post_content LIKE ‘%:”textarea”%’ ) OR ( c.post_content LIKE ‘%:”wysiwyg”%’ ) OR ( c.post_content LIKE ‘%:”select”%’ ) OR ( c.post_content LIKE ‘%:”checkbox”%’ ) OR ( c.post_content LIKE ‘%:”radio”%’ )) ) WHERE 1=1 AND wp_posts.ID NOT IN (1464) AND ( wp_term_relationships.term_taxonomy_id IN (67) ) AND ( ( ( b.meta_id IS NOT NULL ) AND ( c.ID IS NOT NULL ) AND ( a.meta_value LIKE ‘%plantation%’ ) ) OR ( ( wp_posts.post_title LIKE ‘%plantation%’ ) OR ( wp_posts.post_content LIKE ‘%plantation%’ ) OR ( wp_posts.post_excerpt LIKE ‘%plantation%’ ) ) ) AND ((wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘page’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘attachment’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘alkoholi’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘drinkki’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘valineet’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’))) GROUP BY wp_posts.ID ORDER BY wp_posts.post_title LIKE ‘{c05b72c5543863fd91545c98ab6ea129c5be692966993383746cb37bdf19ec97}plantation{c05b72c5543863fd91545c98ab6ea129c5be692966993383746cb37bdf19ec97}’ DESC, wp_posts.post_date DESC LIMIT 0, 50
2023-09-05 13:49:06 : SELECT DISTINCT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta AS a ON ( a.post_id = wp_posts.ID ) LEFT JOIN wp_postmeta AS b ON ( (( b.post_id = a.post_id )) AND (( b.meta_key LIKE CONCAT( ‘_’, a.meta_key ) )) ) LEFT JOIN wp_posts AS c ON ( ( c.post_name = b.meta_value ) AND ( c.post_type = ‘acf-field’ ) AND (( c.post_content LIKE ‘%:”text”%’ ) OR ( c.post_content LIKE ‘%:”textarea”%’ ) OR ( c.post_content LIKE ‘%:”wysiwyg”%’ ) OR ( c.post_content LIKE ‘%:”select”%’ ) OR ( c.post_content LIKE ‘%:”checkbox”%’ ) OR ( c.post_content LIKE ‘%:”radio”%’ )) ) WHERE 1=1 AND wp_posts.ID NOT IN (1464) AND ( wp_term_relationships.term_taxonomy_id IN (67) ) AND ( ( ( b.meta_id IS NOT NULL ) AND ( c.ID IS NOT NULL ) AND ( a.meta_value LIKE ‘%scofflaw%’ ) ) OR ( ( wp_posts.post_title LIKE ‘%scofflaw%’ ) OR ( wp_posts.post_content LIKE ‘%scofflaw%’ ) OR ( wp_posts.post_excerpt LIKE ‘%scofflaw%’ ) ) ) AND ((wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘page’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘attachment’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘alkoholi’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘drinkki’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘valineet’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’))) GROUP BY wp_posts.ID ORDER BY wp_posts.post_title LIKE ‘{0bdc5a20dc7d8110622f8132d71f88411e41db654a6ca6dd950fbdc0c6fac699}scofflaw{0bdc5a20dc7d8110622f8132d71f88411e41db654a6ca6dd950fbdc0c6fac699}’ DESC, wp_posts.post_date DESC LIMIT 0, 50
2023-09-05 13:49:13 : SELECT DISTINCT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta AS a ON ( a.post_id = wp_posts.ID ) LEFT JOIN wp_postmeta AS b ON ( (( b.post_id = a.post_id )) AND (( b.meta_key LIKE CONCAT( ‘_’, a.meta_key ) )) ) LEFT JOIN wp_posts AS c ON ( ( c.post_name = b.meta_value ) AND ( c.post_type = ‘acf-field’ ) AND (( c.post_content LIKE ‘%:”text”%’ ) OR ( c.post_content LIKE ‘%:”textarea”%’ ) OR ( c.post_content LIKE ‘%:”wysiwyg”%’ ) OR ( c.post_content LIKE ‘%:”select”%’ ) OR ( c.post_content LIKE ‘%:”checkbox”%’ ) OR ( c.post_content LIKE ‘%:”radio”%’ )) ) WHERE 1=1 AND wp_posts.ID NOT IN (1464) AND ( wp_term_relationships.term_taxonomy_id IN (67) ) AND ( ( ( b.meta_id IS NOT NULL ) AND ( c.ID IS NOT NULL ) AND ( a.meta_value LIKE ‘%mai%’ ) AND ( a.meta_value LIKE ‘%tai%’ ) ) OR ( ( ( wp_posts.post_title LIKE ‘%mai%’ ) OR ( wp_posts.post_content LIKE ‘%mai%’ ) OR ( wp_posts.post_excerpt LIKE ‘%mai%’ ) ) AND ( ( wp_posts.post_title LIKE ‘%tai%’ ) OR ( wp_posts.post_content LIKE ‘%tai%’ ) OR ( wp_posts.post_excerpt LIKE ‘%tai%’ ) ) ) ) AND ((wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘page’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘attachment’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘alkoholi’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘drinkki’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’)) OR (wp_posts.post_type = ‘valineet’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘acf-disabled’ OR wp_posts.post_status = ‘private’))) GROUP BY wp_posts.ID ORDER BY (CASE WHEN wp_posts.post_title LIKE ‘{1d42e411925e83847698c379dc8958b05f72f90eb7d39b7296fe1eb01f8b01a9}mai tai{1d42e411925e83847698c379dc8958b05f72f90eb7d39b7296fe1eb01f8b01a9}’ THEN 1 WHEN wp_posts.post_title LIKE ‘{1d42e411925e83847698c379dc8958b05f72f90eb7d39b7296fe1eb01f8b01a9}mai{1d42e411925e83847698c379dc8958b05f72f90eb7d39b7296fe1eb01f8b01a9}’ THEN 2 WHEN wp_posts.post_excerpt LIKE ‘{1d42e411925e83847698c379dc8958b05f72f90eb7d39b7296fe1eb01f8b01a9}mai tai{1d42e411925e83847698c379dc8958b05f72f90eb7d39b7296fe1eb01f8b01a9}’ THEN 4 WHEN wp_posts.post_content LIKE ‘{1d42e411925e83847698c379dc8958b05f72f90eb7d39b7296fe1eb01f8b01a9}mai tai{1d42e411925e83847698c379dc8958b05f72f90eb7d39b7296fe1eb01f8b01a9}’ THEN 5 ELSE 6 END), wp_posts.post_date DESC LIMIT 0, 50Yes, I have access to phpmyadmin.
Oh yes, I did install the beta version of the plugin first
@jarkko71k Thank you!
Could you go to phpMyAdmin, to the Variables tab? Please send me a screenshot of the entire configuration – I will compare it with myself and try to find the source of the problem. Due to the fact that there may be confidential information there, please send this message to the following e-mail address:
hello(at)mattplugins.com
. I will check it and get back to you with information.Done & sent
@jarkko71k The problem is not related to my plugin. The root of the problem is that WordPress by default considers posts of type post and page. A does not take into account other types of posts.
For your website, please add the following code to the functions.php file in your theme directory:
add_action( 'pre_get_posts', function( $query ) { if ( is_admin() || ! $query->is_main_query() || ! is_search() ) { return; } $query->set( 'post_type', [ 'post', 'page', 'alkoholi', 'drinkki', 'valineet' ] ); } );
Yes! This works like a charm! Thank you so much!
- The topic ‘Finds nothing from Custom Fields’ is closed to new replies.