4
I have the titles of my last posts, but I also need to search and display the images along with the title. This is a file outside the Wordpress folder, a static page I made in HTML and CSS:
<?php
include('esenergy/wp-load.php'); // Blog path
// Get the last 5 posts
$recent_posts = wp_get_recent_posts(array(
'numberposts' => 4,
'category' => 0,
'orderby' => 'post_date',
'post_type' => 'post',
'post_status' => 'publish'
));
// Display them as list
echo '<ul>';
foreach($recent_posts as $post) {
echo '<li><a href="', get_permalink($post['ID']), '">', $post['post_title'], '</a></li>';
}
echo '</ul>';
I’m trying to do something like this:
https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/
– Caio Felipe Pereira
I upgraded the question and answer, I voted +1 in the answer because of my issue, the previous vote was not mine ;) PS: I would solve this problem by trying a solution similar to this one: How to get Wordpress posts from a single Category using XML-RPC, is kind easy to adapt. Another link of interest: When should you use Wp_query vs query_posts() vs get_posts()?
– brasofilo