• Resolved strike3

    (@strike3)


    Hi,
    We have an issue where a few specific search terms bypass our search.php template. So far, I’ve only found 3 terms that do this: faculty, staff, library

    Two of the terms (faculty and staff) are also the names of custom post types that are using ACF. However, other custom post types (e.g., Trustees) don’t seem to be affected by the issue. The other term (library) is a category of Staff.

    I’ve run some of the suggested diagnostics (https://www.relevanssi.com/knowledge-base/debugging-relevanssi-searching-issues/). These are the results for the term “staff”:

    – Test Results in Admin Search – Works fine
    – Parameters Relavanssi is using – Seems normal:
    array(67) { [“s”]=> string(5) “staff” [“error”]=> string(0) “” [“m”]=> string(0) “” [“p”]=> int(0) [“post_parent”]=> string(0) “” [“subpost”]=> string(0) “” [“subpost_id”]=> string(0) “” [“attachment”]=> string(0) “” [“attachment_id”]=> int(0) [“name”]=> string(0) “” [“pagename”]=> string(0) “” [“page_id”]=> int(0) [“second”]=> string(0) “” [“minute”]=> string(0) “” [“hour”]=> string(0) “” [“day”]=> int(0) [“monthnum”]=> int(0) [“year”]=> int(0) [“w”]=> int(0) [“category_name”]=> string(0) “” [“tag”]=> string(0) “” [“cat”]=> string(0) “” [“tag_id”]=> string(0) “” [“author”]=> string(0) “” [“author_name”]=> string(0) “” [“feed”]=> string(0) “” [“tb”]=> string(0) “” [“paged”]=> int(0) [“meta_key”]=> string(0) “” [“meta_value”]=> string(0) “” [“preview”]=> string(0) “” [“sentence”]=> string(0) “” [“title”]=> string(0) “” [“fields”]=> string(0) “” [“menu_order”]=> string(0) “” [“embed”]=> string(0) “” [“category__in”]=> array(0) { } [“category__not_in”]=> array(0) { } [“category__and”]=> array(0) { } [“post__in”]=> array(0) { } [“post__not_in”]=> array(0) { } [“post_name__in”]=> array(0) { } [“tag__in”]=> array(0) { } [“tag__not_in”]=> array(0) { } [“tag__and”]=> array(0) { } [“tag_slug__in”]=> array(0) { } [“tag_slug__and”]=> array(0) { } [“post_parent__in”]=> array(0) { } [“post_parent__not_in”]=> array(0) { } [“author__in”]=> array(0) { } [“author__not_in”]=> array(0) { } [“ignore_sticky_posts”]=> bool(false) [“suppress_filters”]=> bool(false) [“cache_results”]=> bool(true) [“update_post_term_cache”]=> bool(true) [“update_menu_item_cache”]=> bool(false) [“lazy_load_term_meta”]=> bool(true) [“update_post_meta_cache”]=> bool(true) [“post_type”]=> string(3) “any” [“posts_per_page”]=> int(10) [“nopaging”]=> bool(false) [“comments_per_page”]=> string(2) “50” [“no_found_rows”]=> bool(false) [“search_terms_count”]=> int(1) [“search_terms”]=> array(1) { [0]=> string(5) “staff” } [“search_orderby_title”]=> array(1) { [0]=> string(164) “wp_posts.post_title LIKE ‘{e16649c1cd11416fffe12baa2e484766fed2ea80f5838b3b5f034d0d98031f95}staff{e16649c1cd11416fffe12baa2e484766fed2ea80f5838b3b5f034d0d98031f95}'” } [“order”]=> string(4) “DESC” }

    – MySQL Query (also seems normal)
    string(487) “SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * 5 + relevanssi.content * 1 + relevanssi.comment * 0.75 + relevanssi.tag * 0.75 + relevanssi.link * 0 + relevanssi.author + relevanssi.category * 0.75 + relevanssi.excerpt + relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf FROM wp_relevanssi AS relevanssi WHERE (relevanssi.term LIKE ‘staff%’ OR relevanssi.term_reverse LIKE CONCAT(REVERSE(‘staff’), ‘%’)) ORDER BY tf DESC LIMIT 500”

    – Look at results (probably normal)
    array(83) { [6438]=> float(2978.5845718879) [65]=> float(1241.0769049533) [19062]=> float(2482.1538099066) [8929]=> float(2482.1538099066) [29115]=> float(148.92922859439) [16420]=> float(99.286152396263) [27953]=> float(99.286152396263) [15952]=> float(99.286152396263) [13649]=> float(198.57230479253) [21863]=> float(198.57230479253) [5486]=> float(198.57230479253) [22912]=> float(99.286152396263) [5277]=> float(198.57230479253) [7074]=> float(99.286152396263) [6832]=> float(99.286152396263) [29365]=> float(99.286152396263) [15547]=> float(198.57230479253) [29123]=> float(99.286152396263) [11977]=> float(198.57230479253) [8918]=> float(198.57230479253) [28394]=> float(99.286152396263) [6127]=> float(198.57230479253) [29690]=> float(99.286152396263) [30213]=> float(49.643076198131) [30215]=> float(49.643076198131) [8]=> float(99.286152396263) [10]=> float(99.286152396263) [25098]=> float(99.286152396263) [6929]=> float(49.643076198131) [13335]=> float(49.643076198131) [27681]=> float(49.643076198131) [6440]=> float(49.643076198131) [12846]=> float(49.643076198131) [6962]=> float(49.643076198131) [22322]=> float(99.286152396263) [10297]=> float(99.286152396263) [24124]=> float(49.643076198131) [9537]=> float(99.286152396263) [12355]=> float(49.643076198131) [26183]=> float(49.643076198131) [29263]=> float(99.286152396263) [6997]=> float(49.643076198131) [27225]=> float(49.643076198131) [7008]=> float(49.643076198131) [12651]=> float(99.286152396263) [8305]=> float(99.286152396263) [7027]=> float(49.643076198131) [7035]=> float(49.643076198131) [7037]=> float(49.643076198131) [7039]=> float(49.643076198131) [26499]=> float(49.643076198131) [24964]=> float(49.643076198131) [29318]=> float(49.643076198131) [29576]=> float(99.286152396263) [25994]=> float(99.286152396263) [21389]=> float(99.286152396263) [6294]=> float(99.286152396263) [14742]=> float(49.643076198131) [28054]=> float(49.643076198131) [13722]=> float(49.643076198131) [28829]=> float(49.643076198131) [28321]=> float(49.643076198131) [17826]=> float(49.643076198131) [26531]=> float(49.643076198131) [13992]=> float(49.643076198131) [14267]=> float(99.286152396263) [26050]=> float(99.286152396263) [21705]=> float(49.643076198131) [4042]=> float(99.286152396263) [8906]=> float(99.286152396263) [28878]=> float(49.643076198131) [15823]=> float(49.643076198131) [22223]=> float(99.286152396263) [29137]=> float(99.286152396263) [13528]=> float(49.643076198131) [24281]=> float(99.286152396263) [13532]=> float(49.643076198131) [30177]=> float(99.286152396263) [21736]=> float(49.643076198131) [28904]=> float(99.286152396263) [13818]=> float(49.643076198131) [26619]=> float(99.286152396263) [22524]=> float(49.643076198131) }

    – Look at posts returned (partial results, maybe normal?)

    array(10) { [0]=> object(WP_Post)#4992 (27) { [“ID”]=> int(6438) [“post_author”]=> string(1) “2” [“post_date”]=> string(19) “2014-06-05 09:09:08” [“post_date_gmt”]=> string(19) “2014-06-05 14:09:08” [“post_content”]=> string(11399) “[vc_row bg_type=”image” parallax_style=”vcpb-vz-jquery” bg_image_repeat=”no-repeat” bg_override=”full” enable_overlay=”enable_overlay_value” overlay_color=”rgba(0,0,0,0.5)” overlay_pattern=”transperant” overlay_pattern_opacity=”25″ seperator_enable=”seperator_enable_value” margin_top=”-50″ type=”vc_default” css=”.vc_custom_1541245662380{padding-top: 12% !important;padding-bottom: 12% !important;background: #000000 url(https://staging2.diu.edu/wp-content/uploads/2018/10/DIU-quad.jpg?id=18305) !important;}”][vc_column offset=”vc_col-lg-offset-0 vc_col-lg-12 vc_col-md-offset-0 vc_col-md-12 vc_col-sm-offset-0 vc_col-xs-12″ css=”.vc_custom_1476043981108{margin-top: 10px !important;margin-bottom: 10px !important;}”][ultimate_heading main_heading=”ADMINISTRATION & STAFF” main_heading_color=”#ffffff” spacer=”line_only” spacer_position=”bottom” line_height=”3″ main_heading_style=”font-weight:bold;” main_heading_font_size=”desktop:50px;mobile_landscape:38px;mobile:30px;” main_heading_line_height=”desktop:60px;mobile_landscape:48px;mobile:40px;” line_width=”150″ el_class=”accent-border-color” main_heading_margin=”margin-bottom:15px;”][/ultimate_heading][/vc_column][/vc_row]

    [vc_row full_width=”stretch_row” bg_type=”bg_color” bg_color_value=”#f1f1f1″ css=”.vc_custom_1539876416410{padding-top: 50px !important;}”][vc_column][vc_column_text]
    Administration | Emeriti | Student Services | Finance | Library Information Technology | Media Services | CEWA | School Staff

    [/vc_column_text][/vc_column][/vc_row]

    [vc_row full_height=”yes” bg_type=”bg_color” bg_override=”full” css=”.vc_custom_1539875566824{padding-bottom: 20px !important;}” bg_color_value=”#f1f1f1″ el_id=”administration”][vc_column width=”2/3″ offset=”vc_col-lg-offset-2 vc_col-lg-8 vc_col-md-offset-2 vc_col-md-8 vc_col-sm-offset-1 vc_col-xs-offset-1 vc_col-xs-10″ css=”.vc_custom_1540222630373{padding-top: 40px !important;padding-right: 20px !important;padding-left: 20px !important;background-color: #ffffff !important;}”][ultimate_heading main_heading=”Administration” spacer=”line_only” spacer_position=”bottom” line_height=”3″ main_heading_style=”font-weight:bold;” main_heading_font_size=”desktop:30px;” main_heading_line_height=”desktop:40px;” line_width=”100″ el_class=”accent-border-color color-title” spacer_margin=”margin-bottom:50px;” sub_heading_style=”font-weight:bold;” sub_heading_font_size=”desktop:18px;” sub_heading_line_height=”desktop:28px;” main_heading_margin=”margin-bottom:10px;”][/ultimate_heading][vc_column_text][liststaff section=’administration’][/vc_column_text][/vc_column][/vc_row][vc_row bg_type=”bg_color” bg_override=”full” css=”.vc_custom_1665584094852{padding-bottom: 20px !important;}” bg_color_value=”#f1f1f1″ el_id=”emeriti”][vc_column width=”2/3″ offset=”vc_col-lg-offset-2 vc_col-lg-8 vc_col-md-offset-2 vc_col-md-8 vc_col-sm-offset-1 vc_col-xs-offset-1 vc_col-xs-10″ css=”.vc_custom_1540222643553{padding-top: 40px !important;padding-right: 20px !important;padding-left: 20px !important;background-color: #ffffff !important;}”][ultimate_heading main_heading=”Staff Emeriti” spacer=”line_only” spacer_position=”bottom” line_height=”3″ main_heading_style=”font-weight:bold;” main_heading_font_size=”desktop:30px;” main_heading_line_height=”desktop:40px;” line_width=”100″ el_class=”accent-border-color color-title” spacer_margin=”margin-bottom:50px;” sub_heading_style=”font-weight:bold;” sub_heading_font_size=”desktop:18px;” sub_heading_line_height=”desktop:28px;” main_heading_margin=”margin-bottom:10px;” margin_design_tab_text=””][/ultimate_heading][vc_column_text][liststaff section=’emeriti’][/vc_column_text][/vc_column][/vc_row][vc_row full_height=”yes” bg_type=”bg_color” bg_override=”full” css=”.vc_custom_1539875791265{padding-bottom: 20px !important;}” bg_color_value=”#f1f1f1″ el_id=”studentservices”][vc_column width=”2/3″ offset=”vc_col-lg-offset-2 vc_col-lg-8 vc_col-md-offset-2 vc_col-md-8 vc_col-sm-offset-1 vc_col-xs-offset-1 vc_col-xs-10″ css=”.vc_custom_1540222643553{padding-top: 40px !important;padding-right: 20px !important;padding-left: 20px !important;background-color: #ffffff !important;}”][ultimate_heading main_heading=”Student Services” spacer=”line_only” spacer_position=”bottom” line_height=”3″ main_heading_style=”font-weight:bold;” main_heading_font_size=”desktop:30px;” main_heading_line_height=”desktop:40px;” line_width=”100″ el_class=”accent-border-color color-title” spacer_margin=”margin-bottom:50px;” sub_heading_style=”font-weight:bold;” sub_heading_font_size=”desktop:18px;” sub_heading_line_height=”desktop:28px;” main_heading_margin=”margin-bottom:10px;”][/ultimate_heading][vc_column_text][liststaff section=’student services’][/vc_column_text][/vc_column][/vc_row][vc_row bg_type=”bg_color” bg_override=”full” css=”.vc_custom_1658952588950{padding-bottom: 20px !important;}” bg_color_value=”#f1f1f1″ el_id=”finance”][vc_column width=”2/3″ offset=”vc_col-lg-offset-2 vc_col-lg-8 vc_col-md-offset-2 vc_col-md-8 vc_col-sm-offset-1 vc_col-xs-offset-1 vc_col-xs-10″ css=”.vc_custom_1540222643553{padding-top: 40px !important;padding-right: 20px !important;padding-left: 20px !important;background-color: #ffffff !important;}”][ultimate_heading main_heading=”Finance” spacer=”line_only” spacer_position=”bottom” line_height=”3″ main_heading_style=”font-weight:bold;” main_heading_font_size=”desktop:30px;” main_heading_line_height=”desktop:40px;” line_width=”100″ el_class=”accent-border-color color-title” spacer_margin=”margin-bottom:50px;” sub_heading_style=”font-weight:bold;” sub_heading_font_size=”desktop:18px;” sub_heading_line_height=”desktop:28px;” main_heading_margin=”margin-bottom:10px;”][/ultimate_heading][vc_column_text][liststaff section=’Finance’][/vc_column_text][/vc_column][/vc_row][vc_row full_height=”yes” bg_type=”bg_color” bg_override=”full” css=”.vc_custom_1539875891767{padding-bottom: 20px !important;}” bg_color_value=”#f1f1f1″ el_id=”library”][vc_column width=”2/3″ offset=”vc_col-lg-offset-2 vc_col-lg-8 vc_col-md-offset-2 vc_col-md-8 vc_col-sm-offset-1 vc_col-xs-offset-1 vc_col-xs-10″ css=”.vc_custom_1540222658002{padding-top: 40px !important;padding-right: 20px !important;padding-left: 20px !important;background-color: #ffffff !important;}”][ultimate_heading main_heading=”Library” spacer=”line_only” spacer_position=”bottom” line_height=”3″ main_heading_style=”font-weight:bold;” main_heading_font_size=”desktop:30px;” main_heading_line_height=”desktop:40px;” line_width=”100″ el_class=”accent-border-color color-title” spacer_margin=”margin-bottom:50px;” sub_heading_style=”font-weight:bold;” sub_heading_font_size=”desktop:18px;” sub_heading_line_height=”desktop:28px;” main_heading_margin=”margin-bottom:10px;”][/ultimate_heading]

    I can’t tell what template is being used to display these unusual results. My guess is that this is some type of issue with ACF, or maybe with a shortcode that is on specific pages in the result posts? I have tried rebuilding the index and disabling and re-enabling Relevanssi and other plugins (e.g., Search and Filter Pro, Yoast SEO, Siteground Optimizer, etc.) without any luck. I can also post our custom search.php file if that would be helpful, but didn’t want to make this first post too overwhelming.

    Thanks in advance for any ideas you might have.

    Sincerely,
    Matt

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mikko Saari

    (@msaari)

    It seems to be the blog template (based on the body tag on the page). The debugging results are correct; what’s happening is that Relevanssi is working correctly, but when the results are created, your theme misunderstands something.

    Does the problem go away if you disable custom excerpts in Relevanssi settings?

    Thread Starter strike3

    (@strike3)

    Yes, that fixed the issue. Thanks! I guess that will work since it still lists page URLs though there isn’t much text with most search results now.

    I’m a little curious about what could be happening with our theme and why only a few search terms seemed to be triggering it. If I could figure that part out, I imagine the theme authors would be willing to make a change to make their theme more compatible with Relevanssi. We’re using one of the top-selling ones over on ThemeForest (the7 theme).

    Thanks again for the quick help on this!

    Sincerely,
    Matt

    Plugin Author Mikko Saari

    (@msaari)

    It’s probably the personnel listing element. That element is not compatible with Relevanssi excerpts. Is that a Visual Composer element? You could probably fix this so that that element is removed from the excerpts, which would leave you with working excerpts for other posts.

    The solution is to use the relevanssi_pre_excerpt_content filter hook to remove the personnel listing from the page before Relevanssi creates the excerpts.

    Thread Starter strike3

    (@strike3)

    That worked perfectly! Thank you so much. That one is a custom shortcode, so it makes sense it would be the problem here. I should have realized that earlier. We made the shortcode because Visual Composer didn’t have a good way to display some of our ACF data. I’m guessing it’s probably how the shortcode is creating its loop or something like that causing this problem. Anyway, no need to go further on this–your solution with excluding the shortcode will work perfectly for what we need.

    In case it’s helpful to anyone later on, here’s the functions.php filter used to exclude the shortcode (in this case, our shortcode is [listemployee], and it can have other parameters/text within the shortcode):

    add_filter( ‘relevanssi_pre_excerpt_content’, ‘rlv_listemployee’, 8 );
    function rlv_listemployee( $content ) {
        return preg_replace( ‘/\[listemployee.*\]/’, ‘\1’, $content );
    }

    Thank you again!
    Matt

    Plugin Author Mikko Saari

    (@msaari)

    Good that you got that sorted out. As a general rule, shortcodes should never use WP_Query to fetch posts. Using WP_Query is pretty much restricted to template files (and there it’s often not a good idea). In shortcodes, the non-problematic way is using get_posts().

    Thread Starter strike3

    (@strike3)

    Thank you once again! I checked that shortcode, and sure enough, it was using query_posts, which (from what I’m reading) may be worse than WP_Query. I’ve rewritten it to use get_posts instead, and now it is working fine with Relevanssi. Thank you for the amazing support here.

    Sincerely,
    Matt

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Specific search terms bypassing search.php template’ is closed to new replies.