• Hi there,

    I have a really odd query, your plugin is working amazingly welly for a handful of custom post types and their associated Advanced Custom Fields, but for one custom post type it will only return results if the keyword/s is within the standard fields, ie title.

    This is the code

                    $posts_checker = new WP_Query(array(
                        'nopaging'   => true,
                        'post_type'     => 'buglist',
                        's' => $search_keyword,
                    ));

    Do you know anything that would cause for that?

    Thanks ever so much,
    TJ

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @tjldesigns ,

    Thank you for your message. I will try to help you, but I need some extra things from you:

    1. A screenshot of a command to perform the database and results (entire window).
    2. SQL query displayed after change in plugin code (https://gbiorczyk.pl/img/8jYkbzF.png) when you try to search for something.
    3. Database dump (only table wp_posts and wp_postmeta tables). Please delete private data from it, if any.
    4. ID of post you want to find..
    5. Version of ACF plugin and version of ACF: Better Search.
    6. Screenshot of your search results (entire browser window).

    Thread Starter tjldesigns

    (@tjldesigns)

    Hi Mateusz,

    Thanks so much for your quick reply, sadly I’m not 100% sure on how to supply all the above but I wonder if this could help, please see below for a search for the word: ‘mallorca’ which has been added into an ACF of 1 x post from 2 different custom post types, one which works, and then the other the one which doesnt, see WP_Query results below:

    Custom post type "buglist" - which is not searching within ACF
    WP_Query Object ( [query] => Array ( [nopaging] => 1 [post_type] => buglist [s] => mallorca ) [query_vars] => Array ( [nopaging] => 1 [post_type] => buglist [s] => mallorca [error] => [m] => [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author] => [author_name] => [feed] => [tb] => [paged] => 0 [meta_key] => [meta_value] => [preview] => [sentence] => [title] => [fields] => [menu_order] => [embed] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [post_name__in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [post_parent__in] => Array ( ) [post_parent__not_in] => Array ( ) [author__in] => Array ( ) [author__not_in] => Array ( ) [suppress_filters] => [ignore_sticky_posts] => [cache_results] => 1 [update_post_term_cache] => 1 [lazy_load_term_meta] => 1 [update_post_meta_cache] => 1 [posts_per_page] => 10 [comments_per_page] => 50 [no_found_rows] => [search_terms_count] => 1 [search_terms] => Array ( [0] => mallorca ) [search_orderby_title] => Array ( [0] => wp_posts.post_title LIKE '{b7770bc27b5cbc0a21e436b4a75465890fdff93fb94ed3cd8e0e3b51c41affbc}mallorca{b7770bc27b5cbc0a21e436b4a75465890fdff93fb94ed3cd8e0e3b51c41affbc}' ) [order] => DESC ) [tax_query] => WP_Tax_Query Object ( [queries] => Array ( ) [relation] => AND [table_aliases:protected] => Array ( ) [queried_terms] => Array ( ) [primary_table] => wp_posts [primary_id_column] => ID ) [meta_query] => WP_Meta_Query Object ( [queries] => Array ( ) [relation] => [meta_table] => [meta_id_column] => [primary_table] => [primary_id_column] => [table_aliases:protected] => Array ( ) [clauses:protected] => Array ( ) [has_or_relation:protected] => ) [date_query] => [request] => SELECT DISTINCT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta AS a ON (a.post_id = wp_posts.ID) INNER JOIN wp_postmeta AS b ON ((b.meta_id = a.meta_id + @@auto_increment_increment) AND (b.post_id = wp_posts.ID)) INNER JOIN wp_posts AS c ON ((c.post_type = 'acf-field') AND ((c.post_content LIKE '%:"text"%') OR (c.post_content LIKE '%:"textarea"%') OR (c.post_content LIKE '%:"wysiwyg"%'))) WHERE 1=1 AND (((c.post_name = b.meta_value) AND (a.meta_value LIKE '%mallorca%')) OR ((wp_posts.post_title LIKE '%mallorca%') OR (wp_posts.post_content LIKE '%mallorca%') OR (wp_posts.post_excerpt LIKE '%mallorca%'))) AND wp_posts.post_type = 'buglist' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_author = 4 AND wp_posts.post_status = 'private' OR wp_posts.post_author = 4 AND wp_posts.post_status = 'hidden') ORDER BY wp_posts.post_title LIKE '{b7770bc27b5cbc0a21e436b4a75465890fdff93fb94ed3cd8e0e3b51c41affbc}mallorca{b7770bc27b5cbc0a21e436b4a75465890fdff93fb94ed3cd8e0e3b51c41affbc}' DESC, wp_posts.post_date DESC [posts] => Array ( ) [post_count] => 0 [current_post] => -1 [in_the_loop] => [comment_count] => 0 [current_comment] => -1 [found_posts] => 0 [max_num_pages] => 0 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => [is_category] => [is_tag] => [is_tax] => [is_search] => 1 [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => [is_privacy_policy] => [is_404] => [is_embed] => [is_paged] => [is_admin] => [is_attachment] => [is_singular] => [is_robots] => [is_posts_page] => [is_post_type_archive] => [query_vars_hash:WP_Query:private] => 832a6c92e7e7695f471152942f93cf46 [query_vars_changed:WP_Query:private] => 1 [thumbnails_cached] => [stopwords:WP_Query:private] => Array ( [0] => about [1] => an [2] => are [3] => as [4] => at [5] => be [6] => by [7] => com [8] => for [9] => from [10] => how [11] => in [12] => is [13] => it [14] => of [15] => on [16] => or [17] => that [18] => the [19] => this [20] => to [21] => was [22] => what [23] => when [24] => where [25] => who [26] => will [27] => with [28] => www ) [compat_fields:WP_Query:private] => Array ( [0] => query_vars_hash [1] => query_vars_changed ) [compat_methods:WP_Query:private] => Array ( [0] => init_query_flags [1] => parse_tax_query ) )
    RESULTS FROM ABOVE QUERY:
    Custom post type "documentation" - which is searching within ACF
    WP_Query Object ( [query] => Array ( [nopaging] => 1 [post_type] => documentation [s] => mallorca ) [query_vars] => Array ( [nopaging] => 1 [post_type] => documentation [s] => mallorca [error] => [m] => [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author] => [author_name] => [feed] => [tb] => [paged] => 0 [meta_key] => [meta_value] => [preview] => [sentence] => [title] => [fields] => [menu_order] => [embed] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [post_name__in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [post_parent__in] => Array ( ) [post_parent__not_in] => Array ( ) [author__in] => Array ( ) [author__not_in] => Array ( ) [suppress_filters] => [ignore_sticky_posts] => [cache_results] => 1 [update_post_term_cache] => 1 [lazy_load_term_meta] => 1 [update_post_meta_cache] => 1 [posts_per_page] => 10 [comments_per_page] => 50 [no_found_rows] => [search_terms_count] => 1 [search_terms] => Array ( [0] => mallorca ) [search_orderby_title] => Array ( [0] => wp_posts.post_title LIKE '{b7770bc27b5cbc0a21e436b4a75465890fdff93fb94ed3cd8e0e3b51c41affbc}mallorca{b7770bc27b5cbc0a21e436b4a75465890fdff93fb94ed3cd8e0e3b51c41affbc}' ) [order] => DESC ) [tax_query] => WP_Tax_Query Object ( [queries] => Array ( ) [relation] => AND [table_aliases:protected] => Array ( ) [queried_terms] => Array ( ) [primary_table] => wp_posts [primary_id_column] => ID ) [meta_query] => WP_Meta_Query Object ( [queries] => Array ( ) [relation] => [meta_table] => [meta_id_column] => [primary_table] => [primary_id_column] => [table_aliases:protected] => Array ( ) [clauses:protected] => Array ( ) [has_or_relation:protected] => ) [date_query] => [request] => SELECT DISTINCT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta AS a ON (a.post_id = wp_posts.ID) INNER JOIN wp_postmeta AS b ON ((b.meta_id = a.meta_id + @@auto_increment_increment) AND (b.post_id = wp_posts.ID)) INNER JOIN wp_posts AS c ON ((c.post_type = 'acf-field') AND ((c.post_content LIKE '%:"text"%') OR (c.post_content LIKE '%:"textarea"%') OR (c.post_content LIKE '%:"wysiwyg"%'))) WHERE 1=1 AND (((c.post_name = b.meta_value) AND (a.meta_value LIKE '%mallorca%')) OR ((wp_posts.post_title LIKE '%mallorca%') OR (wp_posts.post_content LIKE '%mallorca%') OR (wp_posts.post_excerpt LIKE '%mallorca%'))) AND wp_posts.post_type = 'documentation' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_author = 4 AND wp_posts.post_status = 'private' OR wp_posts.post_author = 4 AND wp_posts.post_status = 'hidden') ORDER BY wp_posts.post_title LIKE '{b7770bc27b5cbc0a21e436b4a75465890fdff93fb94ed3cd8e0e3b51c41affbc}mallorca{b7770bc27b5cbc0a21e436b4a75465890fdff93fb94ed3cd8e0e3b51c41affbc}' DESC, wp_posts.post_date DESC [posts] => Array ( [0] => WP_Post Object ( [ID] => 8642 [post_author] => 51 [post_date] => 2019-08-13 09:14:22 [post_date_gmt] => 2019-08-13 09:14:22 [post_content] => [post_title] => Information Bulletin 170 - ORDS deployment available for NPS Housing [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => information-bulletin-170-ords-deployment-available-for-nps-housing [to_ping] => [pinged] => [post_modified] => 2019-09-05 19:51:03 [post_modified_gmt] => 2019-09-05 19:51:03 [post_content_filtered] => [post_parent] => 0 [guid] => https://customersupport.northgateps.temporarywebsiteaddress.com/?post_type=documentation&p=8642 [menu_order] => 0 [post_type] => documentation [post_mime_type] => [comment_count] => 0 [filter] => raw ) ) [post_count] => 1 [current_post] => -1 [in_the_loop] => [post] => WP_Post Object ( [ID] => 8642 [post_author] => 51 [post_date] => 2019-08-13 09:14:22 [post_date_gmt] => 2019-08-13 09:14:22 [post_content] => [post_title] => Information Bulletin 170 - ORDS deployment available for NPS Housing [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => information-bulletin-170-ords-deployment-available-for-nps-housing [to_ping] => [pinged] => [post_modified] => 2019-09-05 19:51:03 [post_modified_gmt] => 2019-09-05 19:51:03 [post_content_filtered] => [post_parent] => 0 [guid] => https://customersupport.northgateps.temporarywebsiteaddress.com/?post_type=documentation&p=8642 [menu_order] => 0 [post_type] => documentation [post_mime_type] => [comment_count] => 0 [filter] => raw ) [comment_count] => 0 [current_comment] => -1 [found_posts] => 1 [max_num_pages] => 0 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => [is_category] => [is_tag] => [is_tax] => [is_search] => 1 [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => [is_privacy_policy] => [is_404] => [is_embed] => [is_paged] => [is_admin] => [is_attachment] => [is_singular] => [is_robots] => [is_posts_page] => [is_post_type_archive] => [query_vars_hash:WP_Query:private] => 5198cd590489e78e4a4c5f4f455ec006 [query_vars_changed:WP_Query:private] => 1 [thumbnails_cached] => [stopwords:WP_Query:private] => Array ( [0] => about [1] => an [2] => are [3] => as [4] => at [5] => be [6] => by [7] => com [8] => for [9] => from [10] => how [11] => in [12] => is [13] => it [14] => of [15] => on [16] => or [17] => that [18] => the [19] => this [20] => to [21] => was [22] => what [23] => when [24] => where [25] => who [26] => will [27] => with [28] => www ) [compat_fields:WP_Query:private] => Array ( [0] => query_vars_hash [1] => query_vars_changed ) [compat_methods:WP_Query:private] => Array ( [0] => init_query_flags [1] => parse_tax_query ) )
    RESULTS FROM ABOVE QUERY:
    8642 : Information Bulletin 170 – ORDS deployment available for NPS Housing

    The code which generated the above is:

                            echo '<h2>Custom post type "buglist" - which is not searching within ACF</h2>';
    
                            $posts_checker = new WP_Query(array(
                                'nopaging'   => true,
                                'post_type'     => 'buglist',
                                's' => $search_keyword,
                            ));
    
                            print_r($posts_checker);
    
                            echo '<h3>RESULTS FROM ABOVE QUERY:</h3>';
    
                            if( $posts_checker->have_posts() ):
                                while( $posts_checker->have_posts() ) : $posts_checker->the_post();
                                    echo get_the_ID().' : '.get_the_title() . '<br>';
                                endwhile;                            
                            endif;
    
                            wp_reset_query();  // Restore global post data stomped by the_post().
    
                            echo '<h2>Custom post type "documentation" - which is searching within ACF</h2>';
    
                            $posts_checker = new WP_Query(array(
                                'nopaging'   => true,
                                'post_type'     => 'documentation',
                                's' => $search_keyword,
                            ));
    
                            print_r($posts_checker);
    
                            echo '<h3>RESULTS FROM ABOVE QUERY:</h3>';
    
                            if( $posts_checker->have_posts() ):
                                while( $posts_checker->have_posts() ) : $posts_checker->the_post();
                                    echo get_the_ID().' : '.get_the_title() . '<br>';
                                endwhile;                            
                            endif;
    
                            wp_reset_query();  // Restore global post data stomped by the_post().
    

    And basically the ID of the post from the ‘buglist’ is ID: 7326

    The version of ACF PRO is: Version 5.8.4 and ACF: Better Search is: Version 3.3.2

    Would WP logins be helpful at all, if so I’d just need a more secure location to send those to you :).

    Many thanks,
    TJ

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @tjldesigns,

    Thank you for your message. I need Database dump (only table wp_posts and wp_postmeta tables). Please delete private data from it, if any. You can find contact in my profile.

    Thread Starter tjldesigns

    (@tjldesigns)

    Hi Mateusz,

    Thanks so much for this, I’ve just emailed you the data dumps :).

    Many thanks,
    TJ

    Hi Mateusz,

    I just wanted to check if you’d had a moment to look at the data dumps?

    Thanks ever so much,
    TJ

    Thread Starter tjldesigns

    (@tjldesigns)

    Sorry Mateusz, I replied via my other account above, but if you could let me know if you’ve had a moment to look at the data dumps, that would be super :).

    Many thanks for your help,
    TJ

    Thread Starter tjldesigns

    (@tjldesigns)

    Hi Mateusz,

    So so sorry to keep chasing but I just wondered if you had been able to see why this might not be working?

    Thanks ever so much,
    TJ

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Plugin for all but one custom post type’ is closed to new replies.