在 WordPress 可以使用 wp_get_recent_posts() 抓取網站最新文章,可以傳入一個陣列帶入相對應的參數,之後會回傳 post 可以參考 get_post() 取得對應的內容。

這邊用一個簡單的範例示範:

<?php
    $recent_posts = wp_get_recent_posts(array(
        'numberposts' => 4, // Number of recent posts thumbnails to display
        'post_status' => 'publish' // Show only the published posts
    ));
    foreach( $recent_posts as $post_item ) : ?>
        <li>
            <a href="<?php echo get_permalink($post_item['ID']) ?>">
                <?php echo get_the_post_thumbnail($post_item['ID'], 'full'); ?>
                <p><?php echo $post_item['post_title'] ?></p>
            </a>
        </li>
<?php endforeach; ?>

藉由 wp_get_recent_posts() 取得物件後就可以利用迴圈顯示出來了。

參考
wp_get_recent_posts()