<?php
$url = 'https://uahurtado.cl/wp-json/wp/v2/posts';
//$url = 'https://cambiaelmundo.uahurtado.cl/wp-json/wp/v2/posts';
$response = file_get_contents($url);
$posts = json_decode($response);
usort($posts, function($a, $b) {
return $b->date <=> $a->date;
});
$last_post = $posts[0];
$titulo_api = $last_post->title->rendered;
$excerpt_api = $last_post->excerpt->rendered;
$link_api = $last_post->link;
$date_obj = DateTime::createFromFormat('Y-m-d\TH:i:s', $last_post->date);
$fecha_api = $date_obj->format('d/m/Y H:i:s');
echo $titulo_api;
echo $fecha_api;
echo $excerpt_api;
echo $link_api;
?>