while-loop - 不能在while循环中内爆最后一个逗号
问题描述
请帮助无法解决此问题。我想添加谷歌丰富的片段,这就是为什么尝试创建 json 但我无法删除最后一个逗号。即使 implode 也不显示任何逗号我尝试了很多东西,但没有一个解决了我的问题。请帮忙
$carisirket = get_queried_object();
$args = array(
'post_type' => 'MYPOSTTYPE',
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'MYTAX',
'field' => 'slug',
'terms' => $carisirket->slug,
)
)
);
$qq = new WP_Query($args);
if($qq->have_posts()) {
while($qq->have_posts()) : $qq->the_post();
?>
{
"@type" : "Review",
"headline": "<?php echo get_the_title();?>",
"itemReviewed": {
"@type": "Thing",
"name": "<?php echo $term->name;?>"
},
"author" : {
"@type" : "Person",
"name" : "<?php echo get_the_author();?>",
"url": ""
},
"reviewBody" : "<?php echo get_the_title() ; ?>",
"datePublished" : "<?php echo get_the_date(); ?>",
"reviewRating" : {
"@type" : "Rating",
"ratingValue" : "<?php echo get_post_meta(get_the_ID(), 'ratings_3421372395', true); ?>",
"bestRating" : "5",
"worstRating" : "0"
},
"publisher": {
"@type": "Organization",
"name": "Şikayetimvar.az",
"sameAs": "https://sikayetimvar.az",
"logo": {
"@type": "ImageObject",
"url": "https://XXXXXX.COM/wp-content/uploads/2021/01/logo.png",
"width": 200,
"height": 50
}
}
} <?php echo implode(',', $qq); endwhile;} ?>
解决方案
推荐阅读
- google-chrome-extension - 如何使 Chrome 扩展程序在加载时自动运行
- javascript - 无论如何在JavaScript中注册一个图像的点击,忽略透明像素?(就像他们点击了一个圆圈或一个blob)
- search - MarkLogic 地理空间表示和后续搜索
- vba - 如果不重复,如何突出显示选定的文本?
- swift - SwiftUI VStack 间距:无法正常工作
- angular - Angular Google Maps 模块在本地渲染,但不在生产环境中
- java -
要么被声明为抽象,要么在中实现抽象方法 onBindViewHolder(VH,int) - node.js - 为什么会发生这种情况,res.redirect() 方法的范围仅限于 express 中的 findByIdAndRemove 方法
- spring-boot - Spring boot千分尺datadog套接字连接错误
- node.js - 使用 res.redirect() 时,带有 Express 的 Node.js 不会重定向到外部 URL