Created
May 31, 2019 05:15
-
-
Save fernandiez/031c22b09e1e80e4c397790a53857e2c to your computer and use it in GitHub Desktop.
Remote WordPress API REST request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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