开发者

wordpress add thumbnail to post Excerpts plugin or method

I am looking for a way to add thumbnail images to post Excerpts.

I've installed: SuperSlider-Excerpt and Thumbnail For Excerpts plugins but I need to specifica开发者_高级运维lly assign the thumbnail that I want to use per post or automatically get the featured image to display as the thumbnail.

Anyone know a method or plugin that can do this please?


You can do this pretty easily with Wordpress. Like Francy said, the_post_thumbnail() will add the featured image you have picked on the post edit page in the admin section.

First you need to set up your thumbnails in your functions.php file. This is in the root directory of your theme (wp-content/themes/your-theme). Write this:

add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 200, 200, false ); // Set your size, and clipping options

This would make thumbnails 200x200. You may want something else, so put whatever number you want in there.

Now that thumbnails are active, you can use the the_post_thumbnail() throughout your site, inside the loop, to display the thumbnail you've picked.

For example, if you want them to appear on the index page, head to index.php in your theme root directory, and write , right before . Experiment with where these appear, and get it in the right place for you.


Try within the loop:

the_post_thumbnail("thumbnail");

Or what also helped me was:

<?php
    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail'); 
    $theImageSource = $image[0];
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜