我在WordPress后端使用AngularJS应用程序。我能够使用WP REST API v2检索注释。,使用以下url
/wp json/wp/v2/comments?立柱=1324
但有没有办法在WP REST API v2中发布评论。我在文档中找不到任何东西。谢谢
我在WordPress后端使用AngularJS应用程序。我能够使用WP REST API v2检索注释。,使用以下url
/wp json/wp/v2/comments?立柱=1324
但有没有办法在WP REST API v2中发布评论。我在文档中找不到任何东西。谢谢
查看评论文档-http://v2.wp-api.org/reference/comments/
以及以下语法:
https://www.example.com/wp-json/wp/v2/comments?author=Your%20Name%20Here&author_email=your-email-address@website-address-here.com&author_name=Your%20Name%20Here&content=Your%20Comment%20Here&post=1604252
类似的问题,我回来了:
{"code":"rest_comment_login_required","message":"Sorry, you must be logged in to comment.","data":{"status":401}}
正在查找代码“rest\\u comment\\u login\\u required”,这是第一个结果之一:WP_REST_Comments_Controller::create_item_permissions_check.所以从v4开始。7.0有一个名为\'rest_allow_anonymous_comments\' 默认情况下返回false。因此,默认情况下,即使Wordpress设置另有指示,您也无法进行评论。
您可以通过添加以下内容将其重新打开:
function filter_rest_allow_anonymous_comments() {
return true;
}
add_filter(\'rest_allow_anonymous_comments\',\'filter_rest_allow_anonymous_comments\');
给你:http://www.contradodigital.com/2016/04/06/post-comments-wordpress-rest-api-version-2/
我必须自己做这件事,官方WordPress API v2中的文档目前不是最好的。
评论。php <?php $args=array( \'type\'=> \'comment\', \'callback\'=>\'my_comment_list\', ); ?> <ol class=\"comments-list\"> <?php wp_list_comments($args) ?>