我还停留在API的评论部分。人们可以在网站的主页上填写餐厅,之后他们将被重定向到其他页面,该网站向客户显示有关餐厅的一些信息,包括他们在Google上的图片以及在Google地图中的位置。最近5条评论。但是我不知道如何实现评论部分,这样我也可以在页面上获得5条评论以及te image和google maps位置。
我已经尝试实现它以在页面上获得评论。但是我只是不知道该怎么做。而且还没有弄清楚。
<?php
/**
* Template Name: Trial Form
*/
$placeId = $_GET['pid'];
$placeUrl = API_GATEWAY_HOST . '/place-details?' . http_build_query([
'placeid' => $placeId,
'fields' => 'photo,formatted_address,geometry,name',
'language' => pll_current_language(),
]);
$response = wp_remote_get($placeUrl);
$place = json_decode($response['body'], true);
if ($place['status'] !== 'OK') {
status_header( 404 );
nocache_headers();
include(get_query_template( '404' ));
die();
}
$lat = $place['result']['geometry']['location']['lat'];
$lng = $place['result']['geometry']['location']['lng'];
$photoSrc = (isset($place['result']['photos'])) ?
API_GATEWAY_HOST . '/places-photo?'. http_build_query([
'photoreference' => $place['result']['photos'][0]['photo_reference'],
'maxwidth' => '1600',
])
: 'https://soconnect-website-
uploads.s3.amazonaws.com/uploads/2018/11/placeholder-image.png';
$mapSrc = API_GATEWAY_HOST . '/staticmap?' . http_build_query([
'center' => $lat . ',' . $lng,
'markers' => 'color:red|'. $lat . ',' . $lng,
'size' => '640x220',
'language' => pll_current_language(),
]);
$name = $place['result']['name'];
$address = $place['result']['formatted_address'];
get_header();
?>
<main class="home trial-form">
<div class="page page--full">
<div class="venue-photo" style="background-image: url('<?
=$photoSrc?>')"></div>
<div class="page__content">
<div class="grid">
<div class="grid-unit--6 description">
<?php echo get_field('Article'); ?>
</div>
<div class='grid-unit--4 form'>
<div class="static-map" style="background-image:
url('<?=$mapSrc?>')"></div>
<div class="form--big form--white">
<p class="name"><?=$name?></p>
<p><?= get_field('Form')['description'] ?></p>
<?php
gravity_form(
get_field('Form')['id'],
false,
false,
false,
['address' => $address, 'location' =>
$name]
);
?>
</div>
</div>
</div>
</div>
</div>
</main>
<?
get_footer();
我希望有人可以帮助我为我解决此问题,并可以帮助我实现获得此页面上的评论所需的部分。只要它们起作用,现在它们到哪儿都没关系,因为这就是当前的问题。