WordPress wp_Get_Attach_Thumb_url已满

时间:2015-03-12 作者:DinhTv

My code in index: (show all attachment by one post ID)

<?php query_posts(\'p=1498\'); if (have_posts()) { while (have_posts()) { the_post(); ?>

<?php $args = array( \'post_type\' => \'attachment\', \'numberposts\' => -1, \'orderby\' => \'rand\', \'post_mime_type\' => \'image\' ,\'post_status\' => null, \'post_parent\' => $post->ID ); 
$attachments = get_posts($args);
    if ($attachments) {
    foreach ( $attachments as $attachment ) { ?>
    <img src="<?php echo wp_get_attachment_thumb_url( $attachment->ID, $size = \'full\' )?>" alt="<?php echo get_post_meta($attachment->ID, \'_wp_attachment_image_alt\', true) ?>" />
<?php }} ?>

<?php }} wp_reset_query(); ?>

but image src show it\'s: thumbnail: http://www.mywebsite.vn/wp-content/uploads/2015/03/vcbf-150x80.jpg ?

How to show image full as: http://www.mywebsite.vn/wp-content/uploads/2015/03/vcbf.jpg

Thanks

1 个回复
最合适的回答,由SO网友:CiprianD 整理而成

在foreach循环中尝试以下操作:

$thumb_url = wp_get_attachment_image_src( $attachment->ID, \'full\' );
对于img src:

echo $thumb_url[0];

结束

相关推荐

how to edit attachments?

在将例如文件附加到帖子时,如何在事后编辑/删除它们?在帖子编辑器中找不到任何内容。谢谢