问题描述
|
我正在寻找一种添加缩略图以发布摘录的方法。
我已经安装了:SuperSlider-Excerpt和Thumbnail对于Excerpts插件,但是我需要专门指定每个帖子要使用的缩略图,或者自动获取要显示为缩略图的精选图像。
有人知道可以执行此操作的方法或插件吗?
解决方法
您可以使用Wordpress轻松完成此操作。就像Francy所说的,the_post_thumbnail()将在管理部分的帖子编辑页面上添加您选择的特色图片。
首先,您需要在functions.php文件中设置缩略图。这位于主题的根目录(wp-content / themes / your-theme)中。这样写:
add_theme_support( \'post-thumbnails\' );
set_post_thumbnail_size( 200,200,false ); // Set your size,and clipping options
这将使缩略图为200x200。您可能还需要其他东西,因此请在其中输入任何数量。
现在,缩略图已处于活动状态,您可以在循环内的整个站点中使用the_post_thumbnail()来显示您选择的缩略图。
例如,如果您希望它们出现在索引页面上,请转到主题根目录中的index.php,并在之前写。试用这些内容的显示位置,然后将其放置在适合您的位置。
, 在循环内尝试:
the_post_thumbnail(\"thumbnail\");
还是对我有帮助的是:
<?php
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ),\'thumbnail\');
$theImageSource = $image[0];
?>