【问题标题】:Featured Image on WP [duplicate]WP上的特色图片[重复]
【发布时间】:2014-09-28 15:07:03
【问题描述】:

我有一个小问题...当我想在我的帖子中显示特色图片时,选择的尺寸不起作用(照片以它自己的尺寸显示)。而且我希望特色图片以与帖子总宽度相同的宽度显示,但我不知道! (THIS IS THE LINK TO THE WEBSITE)

这是我在 PHP 部分中使用的代码

if ( function_exists( 'add_theme_support' ) ) add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size(640, 205);

如您所见,我选择的尺寸是 640x205,但是当我添加时:

<?php the_post_thumbnail();?>

当我在帖子标题代码下添加该代码时,特色图片以其“自己”的大小显示,并且不显示为帖子总宽度。

我能做什么?

【问题讨论】:

标签: php html css wordpress


【解决方案1】:

尝试使用

the_post_thumbnail( array(width,height) ); 

因为宽度和高度是您的值。

【讨论】:

  • 还是不行:(
【解决方案2】:

在你的主题function.php这个函数下

函数二十三设置(){

add_image_size('我的尺寸', 宽度, 高度, TRUE );

}

the_post_thumbnail('My-Size');

注意:添加add_image_size功能后,请重新上传所有图片或使用“Regenerate Thumbnails”插件重新生成图片后,您可以看到您想要的实际尺寸的图片。

【讨论】:

    【解决方案3】:

    试试这个:

    <?php 
           if(has_post_thumbnail()) {  
              the_post_thumbnail(array(350,300));
            } else {
              echo '<img src="'.get_bloginfo("template_url").'/images/no-image.jpg" width="500" height="393"/>';
            }
    ?>
    

    【讨论】:

      猜你喜欢
      • 2017-10-29
      • 2015-07-16
      • 2011-07-14
      • 1970-01-01
      • 2014-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多