开发者

Getting posts that have thumbnails in Wordpress?

开发者 https://www.devze.com 2023-01-23 09:21 出处:网络
I\'ve been working with WordPress built-in functions for a couple of days now and got everything working this far. However, I am trying to find a solution to only fetch posts that have thumbnails into

I've been working with WordPress built-in functions for a couple of days now and got everything working this far. However, I am trying to find a solution to only fetch posts that have thumbnails into an array/object.

I have a开发者_如何学Golready checked out the Wordpress function references, but have yet not found any solution. How can I achieve this?


The Wordpress codex is pretty sparse on this topic. In WordPress 2.9, "Post Thumbnails" were added. In 3.0, they seem to have been renamed "Featured Images." In your theme, you can easily check to see whether or not a post has a featured image.

Within the main have_posts() loop in your theme, you can:

<?php
    if (has_post_thumbnail()) {
        /* Post has a thumbnail */
    }
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消