php – API response to be stored locally

Question

Using WordPress coding standards, is it possible to refactor the code so that the API response would be stored locally for one day, instead of retrieving the data from the API each time the page loads?

<?php
// Assume "$list_api->get_items()" connects to an API.
$list_items = $list_api->get_items();

if(!empty($list_items)) {
    foreach($list_items as $list_item) {
?>
    <div class="item-container">
        <h2><?php echo $list_item['title']; ?></h2>
        <p><?php echo $list_item['paragraph']; ?></p>
    </div>
<?php
    }
}
?>

0
antonio 1 month 2021-08-17T07:23:09-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse