• Resolved razor7

    (@razor7)


    Hi! I have a plain HTML website with WP in a subfolder (/blog). I need to display latest posts from blog into the plain HTML webpage. Is there a PHP script or some kind of widget to achieve this?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Here’s some basic PHP that requests the posts from the WP REST API, and displays the linked post titles. You’ll want to change $json_url to the Posts Endpoint on your WordPress site at “/blog”.

    <?php 
    
    $json_url = 'https://css-tricks.com/wp-json/wp/v2/posts';
    $json = file_get_contents($json_url);
    $data = json_decode($json, TRUE);
    
    foreach($data as $post): ?>
    
        <a href="<?php echo $post['link']; ?>"><h3 class="post-title"><?php echo $post['title']['rendered']; ?></h3></a>
    
    <?php endforeach; ?>
    Thread Starter razor7

    (@razor7)

    Cooool! Thanks!

    No worries mate, always happy to help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plain HTML website, show latest posts’ is closed to new replies.