I want to add thumbnails in the post in front page. But don't know how to do it. My theme do not support custom_field. one of the category's code is I pasted here.......
<div class="featured">
<h2>HEADLINES</h2>
<!--This is where the thumbnails are found for the homepage bottom section - note the custom field name for this image is "thumbnail". Recommended image size is 70x70, as the stylesheet is written for this size.-->
<?php $recent = new WP_Query("cat=3&showposts=3");
while($recent->have_posts()) : $recent->the_post();?>
<?php the_post_thumbnail(); ?>
<?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
<a href="<?php the_post_thumbnail() ?>" rel="bookmark"><imgstyle="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="alt text" /></a>
<?php else: ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><imgstyle="float:left;margin:0px 10px 0px 0px;" src="<?php bloginfo('template_url'); ?>/images/thumbnail.jp" alt="Default thumbnail" /></a>
<?php endif; ?>
<b><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></b>
<?php the_content_limit(80, ""); ?>
<div style="border-bottom:1px dotted #AFAFAF; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;"></div>
<?php endwhile; ?>
I rename the extension jpg to jp coz stackoverflow donot allow me to add image. I also changed
Prior to WordPress 2.9, thumbnails had to be custom fields. Since then, native support has been added.
Read about it on the Codex: http://codex.wordpress.org/Post_Thumbnails
In a nutshell, add this to your theme's functions.php file:
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
}
Then, add this to your theme where you want the thumbnail to appear:
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?>
You can try this one.
http://wordpress.org/extend/plugins/wp-post-thumbnail
I didn't test it though. Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.