1

我制作了一个单独的 wordpress 页面来显示我所有的特色图像,它们确实会显示,但我需要帮助来了解如何使它们显示为实际尺寸而不是真正的小图像。

 <?php
$the_query = new WP_Query();
$the_query->query("cat=4&nopaging=true");

if ($the_query->have_posts()) : 
while($the_query->have_posts()) : $the_query->the_post();

  if(has_post_thumbnail()) : 
    the_post_thumbnail();
  endif;

endwhile; 
endif; 
wp_reset_postdata();
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); 
?>

<img src='<?php echo $image[0]; ?>' />

那是我现在的代码页面是http://rickwarren.veracitycolab.com/banners/

谢谢!

这就是我的新代码的样子,图像仍然是一样的有什么想法吗?

 <?php
$the_query = new WP_Query();
$the_query->query("cat=4&nopaging=true");
if ($the_query->have_posts()) : 
while($the_query->have_posts()) : $the_query->the_post();

  if(has_post_thumbnail()) : 
    the_post_thumbnail();
  endif;

endwhile; 
endif; 
wp_reset_postdata();
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
?>
4

3 回答 3

2

如果在您添加“完整”参数后它仍然没有改变,您可能想尝试 Regenerate Thumbnails 插件: http ://wordpress.org/extend/plugins/regenerate-thumbnails/

通常,当我一直在搞乱自定义缩略图大小时,它对我有帮助。

于 2012-10-15T18:28:21.553 回答
1

wp_get_attachment_image_src()的第二个参数是要返回的图像的大小。在这里使用full应该会给你全尺寸的图像。

$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );

编辑:当然,这部分代码没有做任何事情,因为它在循环之外。

将第 8 行更改为the_post_thumbnail('full');

您可以删除以 开头的行之后的所有内容$image...法典页面在这里

于 2012-10-15T18:10:32.183 回答
1

也传递wp_get_attachment_image_src(...)一个大小参数。在您的情况下,您想要“完整”,所以wp_get_attachment_image_src( $post->ID, 'full' ). 来自该功能的法典

$size (string/array) (可选) 为图片附件显示的图片大小:字符串关键字(缩略图、中、大或完整)或以像素为单位表示宽度和高度的 2 项数组,例如 array(32 ,32)。从 2.5 版开始,此参数不影响媒体图标的大小,媒体图标始终以其原始大小显示。

    Default: thumbnail

CSS 规则仍然可以“缩小”图像,因此如果它不起作用,请检查 HTML 源中的 URL 以确认请求的图像正确,然后检查样式表。

于 2012-10-15T18:12:10.133 回答