multisite - Search returns "Nothing Found" on a sub directory

admin2025-06-06  9

I've created a multisite using subdirectories. The search function, both in backend and frontend, only works on the main site. If I try and do a search in a subdirectory it returns with "Nothing Found" even though I know the page/post exists.

In my debug.log I see this:

[15-Nov-2018 17:40:18 UTC] WordPress database error Unknown column 'wp_posts.post_title' in 'where clause' for query SELECT   wp_2_posts.ID, wp_2_posts.post_parent FROM wp_2_posts  WHERE 1=1 
          AND (
            (wp_posts.post_title LIKE '%home%')
            OR (wp_posts.post_content LIKE '%home%')
            OR EXISTS (
              SELECT * FROM wp_postmeta
                  WHERE post_id = wp_posts.ID
                    AND ( (meta_key LIKE '%title%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%sub_title%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%excerpt_short%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%excerpt_long%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%xyz%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%myACF%' AND meta_value LIKE '%home%') )
            )
            OR EXISTS (
              SELECT * FROM wp_comments
              WHERE comment_post_ID = wp_posts.ID
                AND comment_content LIKE '%home%'
            )
            OR EXISTS (
              SELECT * FROM wp_terms
              INNER JOIN wp_term_taxonomy
                ON wp_term_taxonomy.term_id = wp_terms.term_id
              INNER JOIN wp_term_relationships
                ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
              WHERE (
                taxonomy = 'post_tag'
                    OR taxonomy = 'category'
                    OR taxonomy = 'myCustomTax'
                )
                AND object_id = wp_posts.ID
                AND wp_terms.name LIKE '%home%'
            )
        ) AND wp_2_posts.post_type = 'page' AND (wp_2_posts.post_status = 'publish' OR wp_2_posts.post_status = 'acf-disabled' OR wp_2_posts.post_status = 'future' OR wp_2_posts.post_status = 'draft' OR wp_2_posts.post_status = 'pending' OR wp_2_posts.post_status = 'private')  ORDER BY wp_2_posts.menu_order ASC, wp_2_posts.post_title ASC  made by WP_Posts_List_Table->prepare_items, wp_edit_posts_query, wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, W3TC\DbCache_Wpdb->query, W3TC\DbCache_WpdbInjection_QueryCaching->query, W3TC\_CallUnderlying->query, W3TC\DbCache_Wpdb->query, W3TC\DbCache_WpdbInjection->query, W3TC\DbCache_Wpdb->default_query
[15-Nov-2018 17:40:18 UTC] WordPress database error Unknown column 'wp_posts.post_title' in 'where clause' for query SELECT   wp_2_posts.ID, wp_2_posts.post_parent FROM wp_2_posts  WHERE 1=1 
          AND (
            (wp_posts.post_title LIKE '%home%')
            OR (wp_posts.post_content LIKE '%home%')
            OR EXISTS (
              SELECT * FROM wp_postmeta
                  WHERE post_id = wp_posts.ID
                    AND ( (meta_key LIKE '%title%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%sub_title%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%excerpt_short%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%excerpt_long%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%xyz%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%myACF%' AND meta_value LIKE '%home%') )
            )
            OR EXISTS (
              SELECT * FROM wp_comments
              WHERE comment_post_ID = wp_posts.ID
                AND comment_content LIKE '%home%'
            )
            OR EXISTS (
              SELECT * FROM wp_terms
              INNER JOIN wp_term_taxonomy
                ON wp_term_taxonomy.term_id = wp_terms.term_id
              INNER JOIN wp_term_relationships
                ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
              WHERE (
                taxonomy = 'post_tag'
                    OR taxonomy = 'category'
                    OR taxonomy = 'myCustomTax'
                )
                AND object_id = wp_posts.ID
                AND wp_terms.name LIKE '%home%'
            )
        ) AND wp_2_posts.post_type = 'page' AND (wp_2_posts.post_status = 'publish' OR wp_2_posts.post_status = 'acf-disabled' OR wp_2_posts.post_status = 'future' OR wp_2_posts.post_status = 'draft' OR wp_2_posts.post_status = 'pending' OR wp_2_posts.post_status = 'private')  ORDER BY wp_2_posts.menu_order ASC, wp_2_posts.post_title ASC  made by WP_List_Table->display, WP_List_Table->display_tablenav, WP_Posts_List_Table->extra_tablenav, do_action('manage_posts_extra_tablenav'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WPSEO_Link_Columns->count_objects, WPSEO_Link_Columns->set_count_objects, WP_Query->get_posts, W3TC\DbCache_Wpdb->query, W3TC\DbCache_WpdbInjection_QueryCaching->query, W3TC\_CallUnderlying->query, W3TC\DbCache_Wpdb->query, W3TC\DbCache_WpdbInjection->query, W3TC\DbCache_Wpdb->default_query

I'm not seeing errors pop up anywhere else on the site

Search form code:

<form action="<?php echo esc_url( home_url( '/' ) ); ?>" class="search-form">
    <div class="col-lg-8 col-md-8 col-sm-8 col-xs-12 search-container">
        <input type="search" id="input-s" name="s" placeholder="Search For:" />
    </div>
    <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 submit-btn-container">
        <input type="submit" value="Search"/>
    </div>
</form>

I've created a multisite using subdirectories. The search function, both in backend and frontend, only works on the main site. If I try and do a search in a subdirectory it returns with "Nothing Found" even though I know the page/post exists.

In my debug.log I see this:

[15-Nov-2018 17:40:18 UTC] WordPress database error Unknown column 'wp_posts.post_title' in 'where clause' for query SELECT   wp_2_posts.ID, wp_2_posts.post_parent FROM wp_2_posts  WHERE 1=1 
          AND (
            (wp_posts.post_title LIKE '%home%')
            OR (wp_posts.post_content LIKE '%home%')
            OR EXISTS (
              SELECT * FROM wp_postmeta
                  WHERE post_id = wp_posts.ID
                    AND ( (meta_key LIKE '%title%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%sub_title%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%excerpt_short%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%excerpt_long%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%xyz%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%myACF%' AND meta_value LIKE '%home%') )
            )
            OR EXISTS (
              SELECT * FROM wp_comments
              WHERE comment_post_ID = wp_posts.ID
                AND comment_content LIKE '%home%'
            )
            OR EXISTS (
              SELECT * FROM wp_terms
              INNER JOIN wp_term_taxonomy
                ON wp_term_taxonomy.term_id = wp_terms.term_id
              INNER JOIN wp_term_relationships
                ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
              WHERE (
                taxonomy = 'post_tag'
                    OR taxonomy = 'category'
                    OR taxonomy = 'myCustomTax'
                )
                AND object_id = wp_posts.ID
                AND wp_terms.name LIKE '%home%'
            )
        ) AND wp_2_posts.post_type = 'page' AND (wp_2_posts.post_status = 'publish' OR wp_2_posts.post_status = 'acf-disabled' OR wp_2_posts.post_status = 'future' OR wp_2_posts.post_status = 'draft' OR wp_2_posts.post_status = 'pending' OR wp_2_posts.post_status = 'private')  ORDER BY wp_2_posts.menu_order ASC, wp_2_posts.post_title ASC  made by WP_Posts_List_Table->prepare_items, wp_edit_posts_query, wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, W3TC\DbCache_Wpdb->query, W3TC\DbCache_WpdbInjection_QueryCaching->query, W3TC\_CallUnderlying->query, W3TC\DbCache_Wpdb->query, W3TC\DbCache_WpdbInjection->query, W3TC\DbCache_Wpdb->default_query
[15-Nov-2018 17:40:18 UTC] WordPress database error Unknown column 'wp_posts.post_title' in 'where clause' for query SELECT   wp_2_posts.ID, wp_2_posts.post_parent FROM wp_2_posts  WHERE 1=1 
          AND (
            (wp_posts.post_title LIKE '%home%')
            OR (wp_posts.post_content LIKE '%home%')
            OR EXISTS (
              SELECT * FROM wp_postmeta
                  WHERE post_id = wp_posts.ID
                    AND ( (meta_key LIKE '%title%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%sub_title%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%excerpt_short%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%excerpt_long%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%xyz%' AND meta_value LIKE '%home%')  OR (meta_key LIKE '%myACF%' AND meta_value LIKE '%home%') )
            )
            OR EXISTS (
              SELECT * FROM wp_comments
              WHERE comment_post_ID = wp_posts.ID
                AND comment_content LIKE '%home%'
            )
            OR EXISTS (
              SELECT * FROM wp_terms
              INNER JOIN wp_term_taxonomy
                ON wp_term_taxonomy.term_id = wp_terms.term_id
              INNER JOIN wp_term_relationships
                ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
              WHERE (
                taxonomy = 'post_tag'
                    OR taxonomy = 'category'
                    OR taxonomy = 'myCustomTax'
                )
                AND object_id = wp_posts.ID
                AND wp_terms.name LIKE '%home%'
            )
        ) AND wp_2_posts.post_type = 'page' AND (wp_2_posts.post_status = 'publish' OR wp_2_posts.post_status = 'acf-disabled' OR wp_2_posts.post_status = 'future' OR wp_2_posts.post_status = 'draft' OR wp_2_posts.post_status = 'pending' OR wp_2_posts.post_status = 'private')  ORDER BY wp_2_posts.menu_order ASC, wp_2_posts.post_title ASC  made by WP_List_Table->display, WP_List_Table->display_tablenav, WP_Posts_List_Table->extra_tablenav, do_action('manage_posts_extra_tablenav'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WPSEO_Link_Columns->count_objects, WPSEO_Link_Columns->set_count_objects, WP_Query->get_posts, W3TC\DbCache_Wpdb->query, W3TC\DbCache_WpdbInjection_QueryCaching->query, W3TC\_CallUnderlying->query, W3TC\DbCache_Wpdb->query, W3TC\DbCache_WpdbInjection->query, W3TC\DbCache_Wpdb->default_query

I'm not seeing errors pop up anywhere else on the site

Search form code:

<form action="<?php echo esc_url( home_url( '/' ) ); ?>" class="search-form">
    <div class="col-lg-8 col-md-8 col-sm-8 col-xs-12 search-container">
        <input type="search" id="input-s" name="s" placeholder="Search For:" />
    </div>
    <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 submit-btn-container">
        <input type="submit" value="Search"/>
    </div>
</form>
Share Improve this question asked Nov 19, 2018 at 15:04 ChrisChris 211 silver badge4 bronze badges 2
  • try turning off database / object cache in w3tc and see if that fixes it. – majick Commented Nov 19, 2018 at 15:11
  • @majick that doesn't seem to work. – Chris Commented Nov 20, 2018 at 16:22
Add a comment  | 

1 Answer 1

Reset to default 0

Ok, well this is not exactly to do with subdirectories as such, but there is something mixing up the queries between the subsites...

As you can see the error is saying wp_posts.post_title is not found - because the table selected is actually FROM wp_2_posts... showing the different table prefixes for site 1 wp_ and site 2 wp_2_... so one will not be found within the other.

It could be the form action destination perhaps, try replacing home_url('/') with get_site_url(null, '/'), and hopefully the search form will post to the correct site. Not sure if that will fix it though.

Otherwise it could be a plugin that doesn't support multisite messing up the search query somehow by not using $wpdb->prefix instead of wp_ when creating the query. If that's the case try disabling any plugins that might be doing that...

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749164164a316905.html

最新回复(0)