如何获取所有带有特色图片的WordPress帖子?
问题描述:
在WordPress 3中具有Featured Image功能。如何获取所有带有特色图片的帖子?这是我当前的自定义循环:
In WordPress 3 there is Featured Image functionality. How do i fetch all posts that have a featured image with them? Here is my current custom loop:
$loop = new WP_Query( array( 'posts_per_page' => 15 ) );
答
这应该有效:
$loop = new WP_Query( array( 'posts_per_page' => -1, 'meta_key' => '_thumbnail_id' ) );
不过,我尚未对此进行测试。另外,这可能会获取所有帖子和页面。使用‘post_type’=> 发布
以将其限制为博客文章。
I haven't tested this, though. Also, this will probably fetch all posts and pages. Use 'post_type' => 'post'
to limit it to blog posts.