我有一个WooCommerce网站(https://example.com),我需要控制这个网站的产品使用我的wordpress在localhost(xampp)...plhd--2/>时间我发送创建产品请求使用rest api我收到这个错误:
stdClass对象([代码]=
我怎样才能解决这个问题?
Wordpress拒绝呼叫其他主机。Localhost与示例中的主机不同。com,即使它们位于同一台计算机上。
您可以使用http_request_host_is_external
过滤器来允许localhost:
add_filter( 'http_request_host_is_external', 'allow_localhost', 10, 3 );
function allow_localhost( $allow, $host, $url ) {
if ( $host == 'localhost' ) {
$allow = true;
}
return $allow;
}
您应该在主题的函数中添加上述代码。php
。