Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remote WordPress API REST request
<?php
$uri = 'http://www.dominio.com/wp-json/wp/v2/posts/?page=1&per_page=3';
$json = file_get_contents($uri);
$posts= json_decode($json);
echo "<h1>Listado de entradas</h1><ul>";
foreach ($posts as $post) {
echo "<h2><a href='" . $post->link . "'>" . $post->title->rendered . "</a></h2>\n";
echo "<p>" . $post->excerpt->rendered . "</p>";
echo "<p><a href='" . $post->link . "'>Enlace directo</a></p>\n";
}
echo "</ul>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.