显示要在 Wordpress 上发布的附加图像 [英] Show Attached Image to Post on Wordpress
本文介绍了显示要在 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屋!
查看全文