显示要在Wordpress上发布的附件图像 [英] Show Attached Image to Post on Wordpress

查看:62
本文介绍了显示要在Wordpress上发布的附件图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在Wordpress上显示帖子的附件图像?

How i can show attached images of my posts on Wordpress?

推荐答案

在single.php模板中尝试一下:

Try this in your single.php template:

$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_parent' => $post->ID
);
$images = get_posts( $args );
foreach($images as $image):
echo wp_get_attachment_image($image->ID, 'medium');
endforeach;

这篇关于显示要在Wordpress上发布的附件图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆