首先get_comment_date( \'d\\/m\\/Y\' )
在我的案例中导致了一个PHP通知,所以我将其更改为get_comment_date( \'d\\/m\\/Y\', $comment )
(即,我通过$comment
对象)。
现在代码的问题是$result
应该有一个review
值为审阅数组的项(审阅对象):
$result = [
"@context" => "https://schema.org/",
"@type" => "Organization",
"name" => (get_the_title()),
"image" => (get_the_post_thumbnail_url(get_the_ID(), \'full\')),
"aggregateRating" => [
...
],
\'review\' => $comlistall, // here, a "review" item must exists
/* Or something like so:
\'review\' => array(
array( "@type" => "Review", "headline" => ..., "reviewbody" => ..., ... ),
array( "@type" => "Review", "headline" => ..., "reviewbody" => ..., ... ),
...
),
*/
];
其次,你的
$comlistall
应该生成一个数组,当它以JSON格式表示时,它看起来像第一个
here (参见“更改的文本”)。
因此,要解决此问题:
如上所述$result
, 使用\'review\' => $comlistall
.
更改此选项:
$c = [ "review" => [
"@type" => "Review",
"headline" => (get_comment_meta($comment->comment_ID, WP_REVIEW_COMMENT_TITLE_METAKEY, true)),
"reviewbody" => ($comment->comment_content),
...
] ];
$comlistall[] = $c;
对此(但您可以将审查数据/对象分配给变量
$c
):
$comlistall[] = [
"@type" => "Review",
"headline" => (get_comment_meta($comment->comment_ID, WP_REVIEW_COMMENT_TITLE_METAKEY, true)),
"reviewbody" => ($comment->comment_content),
...
];