我已经使用wordpress实现了我的博客,在我的帖子中iam直接发布图片,但是如果我想要显示它们,他们不会检索。如何从帖子中获取图片
我用the_content()
然后将其显示与该职位的剩余内容的图像任何人都可以建议我如何找回这些图像..?Thanx提前
我已经使用wordpress实现了我的博客,在我的帖子中iam直接发布图片,但是如果我想要显示它们,他们不会检索。如何从帖子中获取图片
我用the_content()
然后将其显示与该职位的剩余内容的图像任何人都可以建议我如何找回这些图像..?Thanx提前
您在内容区域插入图像,所以显然它会作为内容出现在前端。 您需要将图像设置为Featured image
或在text editor
的顶部使用Add media
选项添加它们。
对于来自特色图像检索image
:(单张)
wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full')
对于从添加媒体检索image
:(多图片)
$img_small = get_children('order=ASC&orderby=menu_order&post_type=attachment&post_parent=' . $post->ID);
foreach ($img_small as $imagesmall) {
$attachmentID = $imagesmall->ID;
$attachmentURL = wp_get_attachment_url($attachmentID);
<img src="<?php bloginfo('template_url'); ?>/phpThumb/phpThumb.php?src=<?php echo $attachmentURL; ?>&w=365&h=280&iar=1">alt="Image" />
}
什么是$ post .. ??使用while(have_posts()):the_post();循环显示帖子 – Gautam3164
您需要在header.php中定义'global $ post',它将返回当前帖子中您所站的元素,其中has_post就像是一个循环,就像您要显示的帖子数量一样他们全部 –
好吧老兄我得到了这个....我们也可以使用$ post = get_post()在while循环右.. ?? – Gautam3164
您发布图像从仪表板还是手动编码并添加它?你想达到什么目的,你可以更具体一点吗? – trollster
iam通过仪表板添加图像并添加帖子iam通过图库浏览图像并将其发布到编辑器上 – Gautam3164