我想显示附件的实际图像,而不是附件的网址。我正在使用此代码,但它显示的是网址:
<?php
$argsThumb = array(
'order' => 'ASC',
'post_type' => 'attachment',
'post_parent' => $post->ID,
'post_status' => null
);
$attachments = get_posts($argsThumb);
if ($attachments) {
foreach ($attachments as $attachment) {
apply_filters('the_title', $attachment->post_title);
echo wp_get_attachment_url($attachment->ID, false, false);
}
}
?>
答案 0 :(得分:0)
也许尝试以下方法:
<?php
$argsThumb = array(
'order' => 'ASC',
'post_type' => 'attachment',
'post_parent' => $post->ID,
'post_status' => null
);
$attachments = get_posts($argsThumb);
if ($attachments) {
foreach ($attachments as $attachment) {
apply_filters('the_title', $attachment->post_title);
echo "<img src='" . wp_get_attachment_url($attachment->ID, false, false) . "' />";
}
}
?>