WordPress.org

Forums

[resolved] wp_get_recent_posts with thumbnails (3 posts)

  1. Yakir Gottesman
    Member
    Posted 2 years ago #

    Hi, I am using wp_get_recent_posts function to get the latest 3 posts, and I want it to take only posts that have post thumbnail. How can I do that?

    Thanks!

  2. keesiemeijer
    moderator
    Posted 2 years ago #

    Try this [untested]:

    $args = array(
    'posts_per_page' => 3,
    'meta_key' => '_thumbnail_id'
    );
    $recent_posts = wp_get_recent_posts( $args );

    http://codex.wordpress.org/Function_Reference/wp_get_recent_posts

  3. Yakir Gottesman
    Member
    Posted 2 years ago #

    Yes! Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.