Algolia搜索索引失败

问题描述:

我在我的WordPress站点中安装了Algolia搜索插件1.7.0。我还设置它,当我进入索引下面显示出来:Algolia搜索索引失败

wp_remote_post() failed, indexing won't work. Checkout the logs for more details. 
URL called: http://45.77.12.19/wp-admin/admin-post.php 
Array 
(
    [headers] => Requests_Utility_CaseInsensitiveDictionary Object 
     (
      [data:protected] => Array 
       (
        [server] => nginx/1.12.0 
        [date] => Tue, 25 Apr 2017 02:23:09 GMT 
        [content-type] => text/html 
        [content-length] => 195 
        [www-authenticate] => Basic realm="Restricted" 
       ) 
     ) 

401 Authorization Required 

我试图在wp-config.php文件添加定义(“ALGOLIA_LOOPBACK_HTTP”,真),随后其他步骤解释:
https://community.algolia.com/wordpress/frequently-asked-questions.html

我现在处于一个死胡同,不确定现在该做什么,因为algolia索引不会发生。我该如何解决这个问题?

WordPress的Algolia插件需要能够通过HTTP或HTTPS访问管理界面。 这是它创建一个循环来处理待处理任务的方式。

根据你的日志:'Basic realm ='Restricted'',你的管理员似乎在基本身份验证(htpasswd)后面受到保护。

要使队列在你的情况下工作,你应该提供插件的凭据。

以下是您需要添加到活动主题的functions.php文件中的内容。

<?php 
// In your current active theme functions.php. 
define('MY_USERNAME', 'test'); 
define('MY_PASSWORD', 'test'); 

function custom_loopback_request_args(array $request_args) { 
    $request_args['headers']['Authorization'] = 'Basic ' . base64_encode(MY_USERNAME . ':' . MY_PASSWORD); 

    return $request_args; 
} 

add_filter('algolia_loopback_request_args', 'custom_loopback_request_args'); 

请注意,由于我们正在努力消除该逻辑,因此在未来几周内可能会发生变化。