2
我需要在wordpress中获得该文章的第一张图片。 我有各种职位。所以对于新帖子,我可以设置精选图片。然而,有数千个旧帖子。我需要从这些帖子中提取第一张图片,以便我可以使用它们进行显示。从wordpress文章获取图片(发布内容)
我使用了http://css-tricks.com/snippets/wordpress/get-the-first-image-from-a-post/的代码,我不认为它适合我。
global $post;
$args = array('posts_per_page' => 10, 'category' => 6);
$myposts = get_posts($args);
foreach($myposts as $post) : setup_postdata($post);
......
.....
endforeach;
我需要从缩略图的形式显示每个帖子的图像,如在一个画廊。我搜查了很多,但无法弄清楚如何。
单个帖子怎么样。假设我想要获取ID已知的帖子的图片。 '$ post-> ID = 12'现在我想让post_content中的图像为这篇文章 – prakashchhetri
然后只需传递ID'$ files = get_children('post_parent = 2&post_type = attachment&post_mime_type = image');' –
@Heera:如何不能获得全尺寸的图像? –