如何获取所有带有特色图片的WordPress帖子? [英] How to fetch all WordPress posts with featured image?
本文介绍了如何获取所有带有特色图片的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.
这篇关于如何获取所有带有特色图片的WordPress帖子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文