这就是我在循环中抓取帖子并在索引页面上显示它们的内容......
<?php the_attachment_link( $attachment->ID , false); ?>
这就是它的结果......
<a href="linkToImage">
<img src="sorceOfImage"/>
</a>
我只想要那个中间部分,而不是把它包裹在链接中。有任何想法吗?非常感谢你!
答案 0 :(得分:0)
您只能获取图片:
<?php echo wp_get_attachment_image( $attachment->ID ); ?>
http://codex.wordpress.org/Function_Reference/wp_get_attachment_image
答案 1 :(得分:0)
怎么样:
<?php echo wp_get_attachment_url( $id ); ?>
的内容
答案 2 :(得分:0)
<?php if (have_posts()) : while(have_posts()) : the_post(); ?>
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => 'any',
'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) : ?>
<ul>
<?php foreach($attachments as $attachment): ?>
<li>
<a href="<?php echo wp_get_attachment_url($attachment->ID, true); ?>">
<img src="<?php echo wp_get_attachment_url($attachment->ID, true); ?>" width="100%"/>
<h3><?php echo $attachment->post_title; ?></h3></a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php endwhile; endif; ?>