How to loop through JSON data in wordpress WP REST API

I managed to solve this and access the JSON data using a foreach loop:

$json = lusso_posts();
#var_dump( $json );
#die();

foreach( $json as $post ) { 
    $titles = $post->title;
    $images = $post->featured_image->guid;
    ?>
    <div class="lusso-posts">
        <div class="image-container"><img src="https://wordpress.stackexchange.com/questions/210472/<?php echo $images; ?>" />    </div>
        <h4><?php echo $titles; ?></h4>
    </div>  
    <?php
}

Leave a Comment