我正在使用此代码,但无法使其100%正常工作。注释返回与之相关的所有内容,但我只想检索具有所需属性的注释。
<?php
$args = array(
\'post_id\' =>$post->ID,
\'status\' => \'approve\',
\'type\' => \'wp_review_comment\',
);
$comments = get_comments( $args );
// Create an empty array
$comlistall = array();
foreach ( $comments as $comment ){
$c = [ "review" => [
"@type" => "Review",
"headline" => (get_comment_meta($comment->comment_ID, WP_REVIEW_COMMENT_TITLE_METAKEY, true)),
"reviewbody" => ($comment->comment_content),
"datePublished" => (get_comment_date( \'d\\/m\\/Y\' )),
"itemReviewed" => [
"@type" => "Organization",
"name" => (get_the_title()),
],
"author " => [
"@type" => "Person",
"name" => ($comment->comment_author),
],
"reviewRating"=> [
"@type" => "Rating",
"ratingValue" => (get_comment_meta($comment->comment_ID, WP_REVIEW_COMMENT_RATING_METAKEY, true)),
],
"publisher" => [
"@type" => "Organization",
"name" => "Sitejury",
"sameAs" => "https://sitejury.com",
],
]
];
$comlistall[] = $c;
};
$result = [
"@context" => "https://schema.org/",
"@type" => "Organization",
"name" => (get_the_title()),
"image" => (get_the_post_thumbnail_url(get_the_ID(), \'full\')),
"aggregateRating" => [
"@type" => "AggregateRating",
"bestRating" => "5",
"worstRating" => "1",
"ratingValue" => (get_post_meta($post->ID, \'wp_review_comments_rating_value\', true)),
"ratingCount" => (get_post_meta($post->ID, \'wp_review_comments_rating_count\', true)),
],
$comlistall,
] ;?>
<script type="application/ld+json"><?php echo json_encode($result); ?></script>
目前,我的问题是,现在的结果在"0" = [{
属性我正在努力摆脱"0" = [{
属性结果url:https://sitejury.com/review/zzzzzz/