Wordpress Algolia搜索索引失败

Wordpress Algolia搜索索引失败,wordpress,search,indexing,algolia,Wordpress,Search,Indexing,Algolia,我已经在我的WordPress网站上安装了Algolia搜索插件1.7.0。我还设置了它,当我进入索引时,会显示以下内容: 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_CaseIn

我已经在我的WordPress网站上安装了Algolia搜索插件1.7.0。我还设置了它,当我进入索引时,会显示以下内容:

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文件中添加define('ALGOLIA\u LOOPBACK\u HTTP',true),并按照其他步骤解释:


我已经走到了死胡同,不知道现在该做什么,因为algolia索引将不会发生。我如何解决这个问题

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

根据您的日志:“Basic realm=”Restricted“,您的管理员似乎受到Basic Auth(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' );