搜索返回子目录中的“Nothing Found”

时间:2018-11-19 作者:Chris

我使用子目录创建了一个多站点。后端和前端的搜索功能仅在主站点上可用。如果我尝试在子目录中进行搜索,即使我知道页面/帖子存在,也会返回“未找到任何内容”。

在我的调试中。日志我看到:

[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
我没有看到网站上其他地方出现错误

搜索表单代码:

<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>

1 个回复
SO网友:majick

好吧,这与子目录本身并不完全相关,但子网站之间的查询有点混淆。。。

正如你所看到的,错误是wp_posts.post_title 找不到-因为所选的表实际上FROM wp_2_posts... 显示站点1的不同表前缀wp_ 和站点2wp_2_... 因此,在另一个中找不到一个。

它可能是表单操作目标,请尝试替换home_url(\'/\') 具有get_site_url(null, \'/\'), 希望搜索表能发布到正确的网站。但不确定这是否能解决问题。

否则,它可能是一个插件,不支持多站点通过不使用$wpdb->prefix 而不是wp_ 创建查询时。如果是这种情况,请尝试禁用任何可能会这样做的插件。。。

结束

相关推荐

用于在AWS上使用WordPress MultiSite的映射域的SSL

我已经在Amazon Web服务器EC2实例上安装了Wordpress Multisite。我在实例上使用弹性IP和负载平衡器。我通过AWS证书管理器为多站点设置了通配符SSL证书,该证书适用于主站点和所有新创建的子域网站。我将此证书应用于负载平衡器。现在,我正在尝试为映射域设置SSL证书。我有域名购买通过名称便宜,并已建立了一个记录的弹性IP。我还创建了一个AWS证书,并通过Namecheap DNS上的CNAME记录对其进行了验证。我将此证书应用于同一个负载平衡器,并在AWS中为指向该负载平衡器的子域