If you need to fetch a list of articles from your wordpress site to show them in another web application then you can use the new JSON API in wordpress to do this.
// get post list $wp_url = 'https://www.yourdomain.co.uk/wp-json/wp/v2/posts?categories=4&_embed'; $wp_json = file_get_contents($wp_url); $wpposts = json_decode($wp_json, TRUE);
Replace the 4 with the category ID you would like to fetch.
You can then loop through $wpposts to show the posts on your website.
An example of this would be
<?php if(isset($wpposts) && is_array($wpposts)) : ?>
<div class="wp-posts pure-g">
<?php foreach($wpposts as $wppost) : ?>
<div class="pure-u-1-2 pure-u-md-1-3">
<a href="news?<?php echo $wppost['id']; ?>">
<div class="wp-post">
<div class="wp-post-image">
<?php if( isset($wppost['_embedded']['wp:featuredmedia'][0]['source_url'])) : ?>
<img src="<?php echo $wppost['_embedded']['wp:featuredmedia'][0]['source_url']; ?>" alt="<?php echo $wppost['_embedded']['wp:featuredmedia'][0]['alt_text']; ?>">
<?php endif; ?>
</div>
<div class="wp-post-body">
<h2><?php echo $wppost['title']['rendered']; ?></h2>
<?php
$a = new \DateTime($wppost['date']);
$b = $a->format('Y-m-d');
?>
<div class="wp-post-date"><?php echo $b; ?></div>
<div class="wp-post-excerpt">
<?php echo $wppost['excerpt']['rendered']; ?>
</div>
</div>
</div>
</a>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>